-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
ElasticSearch Blueprints
By :
A new requirement came into existence to search for products that have a specific attribute value set.
As in, the user should be able to search for a particular product based on any of its attributes. However, these attributes are not fixed and might change on a daily basis. Hence, it's not possible to keep this as a key-value pair. More keys mean more fields and each field costs Lucene a reverse index under the hood. So, a better approach would be to model the data as follows:
/products/product/LCD_TV
{
"name" : "LCD TV",
"tags" : [
{
"tagName" : "company" ,
"value" : "Sony"
},
{
"tagName" : "competitor" ,
"value" : "Toshiba"
}
]
}With this approach, everything looks good, but then, the following query works true for the preceding document:
tags.tagName:company AND tags.value:Toshiba
This is not what we expected. The product actually belongs to the company Sony, but then, it matched against the company Toshiba...
Change the font size
Change margin width
Change background colour