问题
I am new to Solr (Lucene) world. What I am trying to figure out is how would I search within a subset of data? Let me elaborate:
- I have 10 employees in my Employee table in the database.
- Each employee has n number of customers that are stored in the Customers table in the same database.
- When an employee is searching, I want to search only within that employee's customers.
This is not exactly faceted search but I am pretty sure there is a way to do it in Solr looking at all the bells and whistles it has. One way I can think of is to create a separate index for each employee's customer, but that seems quite inefficient.
I will be using this through Solr.NET, but I don't think that should matter much in terms of how this would be implemented but throwing it out there just in case.
回答1:
You woud use FilterQuery - fq
parameter. With this approach you can easily filter customers for selected employee.
Example:
...&fq=employeeId:12
In Solr.NET:
new SolrQueryByField("employeeId", 12)
来源:https://stackoverflow.com/questions/9183898/searching-within-a-subset-of-data-solr