got a little question where I'm currently stuck at.
Here's the use case:
Having a index that provides documents such as IT Services which are provided to the customer. The user want's to search through all available services. That's fairly easy to achieve. Now comes the problem where i am stuck.
Customer A has a special price for the IT-Service DatabaseMigration in example. All other user's will pay the default price.
How can i achieve something like that. Having a document like that. Customer A should pay only 1000.00
{
topic: "DatabaseMigration",
price: 1500.00
category: ["Database.Migration"]
includedWorkHours: 20
}
I've seen people use scripting for this when most prices need some kind of
transformation. You end up using scripted fields and scripted sorts. Its
not 100% the fastest thing but it works pretty well I think.
If you just have some overrides you could index two documents: one for
the default prices and one for the override price. Like so:
Then you filter out the results: add a bool filter with
minimum_should_match=1 and three clauses:
The "just_for" field should be missing
The "just_for" field should contain "customer_c"
The "not_for" field must not contain "customer_c"
You'd need to make not_for and just_for not_analyzed but otherwise this
should work and be faster than running a script on every result. Depending
on the number of products it doesn't really matter though.
Okay thanks for the info.
But just wildly guessing if you have a big index with let's say a thousands of products and let's say 20% of the customer's would have their own price. How can you still organize that ?
You could do that, but if 20% of the customers have an override on 100% of
the stuff its probably going to be a costly way to do it. It might make
more sense just to use a script at search time -or- if customers fall into
dozen or so classes then it'd make sense to have different fields for the
price per class. Or something like that.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.