问题描述
现在我正在 CloudSearch
上执行此请求:
Now I'm doing this request on CloudSearch
:
aws cloudsearchdomain --endpoint-url myUrl search --search-query France --query-options "{'fields':['country']}" --return name
我只想获得唯一的名字,但是我得到带有ID的名字.有办法吗?
I want to get only distinct names but i get names with id.Is there a way to do that ?
推荐答案
对于此示例数组:
country | city | company_name | company_id | product_name | product_id
US | NY | C1N | C1id | P1N | P1id
US | NY | C1N | C1id | P2N | P2id
US | NY | C2N | C2id | P1N | P1id
我想在纽约获得所有不同的company_name和company_id
I want to get all distinct company_name and company_id in NY
我执行此请求: URL/search?q = NY& facet.company_id = {sort:'count'}& q.options = {"defaultOperator":"and","fields":["city"],"operators":["and","or"]}& return = _all_fields
我得到了不同的company_id,但是我没有找到一种方法来同时获得company_name而不提出另一个请求
I get distinct company_id but i don't find a way to get company_name at the same time without making another request
{
"status": {
"rid": "lKzEiL0qCwok24g=",
"time-ms": 93
},
"hits": {
"found": 2,
"start": 0,
"hit": [{
"id": "369998744556855594878962245"
}, {
"id": "3699987477777545245"
}]
},
"facets": {
"company_id": {
"buckets": [{
"value": "C1id",
"count": 2
}, {
"value": "C2id",
"count": 1
}]
}
}
}
解决方案
我找到了一个解决方案:我将原始json数据存储在新列中: json_company = {\"id \":\"C1id \",\名称\":\"C1N \"}
和我的请求:& facet.json_company = {}
I found a solution : I store raw json data in a new column : json_company = {\"id\":\"C1id\",\"name\":\"C1N\"}
and my request : &facet.json_company ={}
我的结果:
"facets": {
"json_company": {
"buckets": [{
"value": "{\"id\":\"C1id\",\"name\":\"C1N\"}",
"count": 2
}, {
"value": "{\"id\":\"C2id\",\"name\":\"C2N\"}",
"count": 1
}]
}
我在Lambda函数中解析JSON!
I parse the JSON in my Lambda function !
这篇关于选择独特的Cloudsearch AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!