Creating Dynamic Facets in Elasticsearch -


i want dynamically create facetts nested type has dynamic attributes.

suppose these articles in index , i'm searching name , brand:

{     name: iphone 16gb     brand: apple     type: smartphone     attributes: {         color: white      } } {     name: ipad     brand: apple     type: tablet     attributes: {         color: black     } } {     name: cruzer usb 16gb     brand: sandisk     type: usb-stick     attributes: {         color: black         capacity: 16gb         usb-standard: usb 2.0     } } {     name: cruzer usb 16gb     brand: sandisk     type: usb-stick     attributes: {         color: red         capacity: 16gb         usb-standard: usb 3.0     } } 

now, if i'm searching 'apple' want have search result has following facets:

brand:     apple 2 type:     smartphone 1     tablet 1 color:     black 1     white 1 

a search '16gb' should include facets:

brand:     apple 1     sandisk 2 type:     smartphone 1     usb-stick 2 color:     black 1     white 1     red 1 capacity:     16gb 2 usb-standard:      usb 3.0 1     usb 2.0 2 

likewise, every article can have arbitrary attributes.

the facetted search brand , type easy, how attrubutes? possible elasticsearch?

i hope can unterstand mean...

try below

post _search {    "query": {       "query_string": {          "query": "apple"       }    },    "facets": {       "tags": {          "terms": {             "fields": ["name","brand","type","attributes.color"]          }       }    } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -