php - elasticsearch generic query that works for any search -


i stuck generic query audit project consists of on million+ records. there generic query generate using php or jquery code? till here using and, or operators same:

    {     "filter": {         "and": {             "filters": [                 {                     "term": {                         "age": "28"                     }                 }             ]         },         "or": {             "filters": [                 {                     "term": {                         "name": "varsh"                     }                 }             ]         }     } } 

is there way can use operator , field search for? ui looks enter image description here

we have quite same approach in our application. users can build own query similar ui (the difference have sub-group, can have nested queries).

we use ast store users queries, :

["a",["o",[{"t":"generic.content","o":"contains","a":"@username"},{"t":"generic.content","o":"contains","a":"#username"]],["a",[{"t":"generic.content","o":"contains","a":"other thing"},{"t":"generic.content","o":"contains","a":"yet thing"}]],["o",[{"t":"generic.lang","o":"equals_lang","a":"fr"},{"t":"generic.lang","o":"equals_lang","a":"en"}]]] 

where ["a", []] group , operator , ["o", []] group or operator.

then use ast build elasticsearch query using bool query (http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html) dynamically.

in our format negation handle @ operator level (contains vs !contains), have group of not operator ["n", []]


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -