elasticsearch filtering by the size of a field that is an array -


How can I filter those documents in which there is an array that is more than N elements?

How can I filter the documents that have a field that is an empty array?

What are the solutions to the aspects? If so, then how?

The following filter should only return documents that have fieldName fields There are at least 10 elements, which is an array. Keep in mind that depending on how many documents it can be expensive based on your index.

  "filter": {"script": {"script": "doc ['fieldname'] .values.length & gt; 10"}}   

Regarding the second question: Do you really have an empty array? Or is it just an array area with a price area? You can use to obtain documents that have no value for specific fields:

  "filter": {"missing": {"field": "user"} }   

Otherwise I think that you need to use the script again, as I have suggested above, just with the input as a separate length. If the length is fixed then I put it in the params section so that the script will be cached by elastic finder and used again, because it is always the same:

 {Code} "{" Param1 ": 10}}}   ": "{" script ": {" script ":" doctor [field name ']. Values.length & param; / Div> 

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -