sicio
sicio

Reputation: 307

Search by multiple criteria in elasticsearch

I'm new in ElasticSearch! I would like to design the mapping optimally. Currently, the first query for products assigned to specific categories in a specific variant takes a long time (about 5 seconds for around 40,000 products in elasticsearch with an extensive request for variants). The next query is much faster than the first one.

A sample pattern in elasticsearch looks like:

"id" : 1,
"title" : "product",
"price" : "1100.00",
"categories" : [ the ids of the product's categories],
"tags" : [ the ids of the product's tags ],
"variants" : [ nested type with properties: name, definition, maybe in the future availability dates]

Maybe someone has already encountered such a problem? Or maybe it could be better modeled? Categories and variants as a separate index linked by a relationship?

Upvotes: 1

Views: 306

Answers (1)

Amit
Amit

Reputation: 32376

First thing first, you are using the nested data type for your variant field and nested data-types are known for their bad performance and please refer to go-jek medium blog on trouble with nested field and see if you can apply the suggestions mentioned in the blog to optimize your search performance.

Also, your second request is faster due to Elasticsearch cache and mostly its shard request cache which you can monitor and confirm.

Upvotes: 1

Related Questions