Array field in elasticsearch returning only matching elements
Asked Answered
R

1

8

I have an index in elasticsearch (tire) with an array field and custom analyzer for ngram with min_ngram = 1 and max_ngram = 10.

Field example

field1: [foo, bar, bof]

I construct a query with value of the field1 'f' and it returns the documents containing 'f' in one of the value in field1.

Question: Is is possible to return only matching values in array, e.g. in case of field1 and query 'f', only 'foo' and 'bof' will be return and 'bar' will be ommited, e.g. field1: [foo, bof]?

Remittent answered 6/2, 2013 at 21:53 Comment(1)
I have the same problem. Did you managed to find a solution?Wendish
K
0

You can achieve that applying highlighter in the elastic search query. where in the response you will get extra highlight field with only matched values.

Keyser answered 3/10, 2019 at 7:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.