Hi!
I am pretty new to elasticsearch. Is there is a way to filter my search results by comparing two values in one document?
I have two fields in my document: inStock, inOtherStock and 3 filter values like: show me all, show me only negative, only positive.
So if
'show me all', I should get all data without filter
'show me only negative' i should get only documents where inStock < inOtherStock
'only positive' I should get only docs where inStock > inOtherStock
My search looks like this:
(search, filterValue)
return {
body: {
query: {
query_string: {
query: search`,
fields: [
'name',
'sku',
'bundleId',
'orders.poNumber',
'otherIndex.ownerEmail',
'otherIndex.modifiedProductName',
'inStock',
'inOtherStock',
],
analyzer: 'standard',
},
},
sort: [{ _id: { order: 'desc' } }],
},
};