Searching over Multiple Index

Hi everyone,

Imaging you have 3 indexes:
Index US has prices in US Dollars
Index EU has prices in Euro
Index UK has prices in Pound Sterling

Now you want to search all of the indexes for docs that have a price of 100 US Dollars.

if one uses a statement like this
ISearchResponse searchResponse =
await ElasticSearchConfig.GetClient().SearchAsync(x => x.Index("USIndex, EUIndex, UKIndex")

how can we normalize the price between all indexes. i.e.
If searching Index US use 100
If searching Index UK use 100 converted to UK Pounds say 100/1.5
If searching Index EU use 100 converted to Euro say 100/1.25

Any assistance would be appreciated.

I think you should have 3 price fields per index :

  • price.dollars
  • price.sterling
  • price.euro

Then, when indexing the documents, you can convert all the possible values, and after for the searches you would just have to search with the proper field (ex. "price.dollars" : 100, on all the indices).

1 Like

Hi klof,
Thanks for responding but the problem is:

1- There are a variable number of currencies and I do not want to have 100 extra fields .

2- The exchange rates varies, so you cant store prices at point of indexing

Any other ides?

Yes I get your point,
So the other approach, would be to use a script query by passing the different currency rates in parameter. The script query is used in a filter context so the source must return a boolean value.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html#_custom_parameters

Hi klof,
Thanks for responding.

If you know scripting, any chance of a sample query using NEST, as we are not very proficient at this.

Many Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.