简体   繁体   中英

How to filter distinct data in CloudSearch:AWS?

I have a query in aws cloudsearch. I did the following things

1) Created domain

2) uploaded the data & created indexing

I have data fields like : user_id, user_name, user_details , etc

My objective is to get the grouped/distinct data of particular field & its total count. In Cloudsearch Group by / Distinct key words not supported. So, I went through the cloudsearch documentation & done it by adding facet.user_id={} in my query string.

But I need user_name field data along with user_id and count.** Please update me regarding this.

Here is my full query : ?q="Tamil Selvan"&facet.user_id={}


Here is my query result :

{
    "status": {
        "rid": "isTcmOYp+AEKhpbc",
        "time-ms": 6
    },
    "hits": {
        "found": 986,
        "start": 0,
        "hit": []
    },
    "facets": {
        "user_id": {
            "buckets": [{
                "value": "5",
                "count": 213
            }, {
                "value": "182",
                "count": 197
            }]
        }
    }
}


My expected result :

{
    "status": {
        "rid": "isTcmOYp+AEKhpbc",
        "time-ms": 6
    },
    "hits": {
        "found": 986,
        "start": 0,
        "hit": []
    },
    "facets": {
        "user_id": {
            "buckets": [{
                "value": "5",
                "user_name":"Tamil Selvan",
                "count": 213
            }, {
                "value": "182",
                "user_name":"Tamil Selvi",
                "count": 197
            }]
        }
    }
}

The proper solution would be to look up the user_names for the user_id facet values from your datastore (which CloudSearch is not, or at least should not be).

CloudSearch is a search solution; you shouldn't be trying to ask it which user_name belongs to some user_id, as that's a question for your data store.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM