0

Our elastic search document currently has following fields: Id, cityId.

It's very easy to aggregate if each document's city field has only 1 cityid i.e. cityid = 1.

But how can we aggregate on cityid if some document have multiple cityid values?

For example, if some document has cityid as (1,2), this shouldn't be treated as a new cityid i.e. (1,2) but this document should consider cityid 1 and cityid 2 as separate keys while aggregation on cityid for these documents.

1 Answer 1

1

If you store the cityid field as an array this will work perfectly. Example:

POST index1/type/
{
   "cityid": [1, 2] 
}

What won't work is if you store it like this:

POST index1/type/
{
   "cityid": "1,2" 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.