문제

I'm trying to understand how to approach search requirements I have.

The first one is a normal product search that I know Solr can handle appropriately, where you search for a term and Solr returns relevant documents.

The second one is a search for products within a certain category. I have a hierarchical structure in my database that consists in a category with many subcategories and those have products.

The thing is, when some very specific words are searched for, the first approach shouldn't be used, instead a search for a category should be done and only products within that category should be returned, which for me is a very basic SQL query (select * from products where categoryId = 1000).

Does Solr should or can be used in the second case? If so, what is the normal approach to use?

도움이 되었습니까?

해결책 2

Yes, you could use similar approach in Solr, by attributing your products with categoryId and later, while searching add filter query similiar to SQL, categoryId:10000

For more info about filter query, take a look here - http://wiki.apache.org/solr/CommonQueryParameters#fq

다른 팁

Besides what @Mysterion proposed of filter queries you should take a look at Solr Facets which gives you very powerful catogory-like searching.

You also might want to consider multivalue field for categoryParentIds which will contain the parent categories that the product is in and thus combined with filter query and or facets will get your parent category searching.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top