开发者

Solr Faceting count drop to zero

The application I work on use Solr to index pages or products of different stores. When I say "products of different stores", it means that a product can be available in store A or store B, but not on store C. If a customer is connected to the store C website and search for a pr开发者_如何学JAVAoduct that is not available in this store, it should not appear in the search result.

I have a "type" field in my schema that permitted me to tell if the document is a "page" or a "product". Now that I have this search constraint, this field contains either "page" or a composite key like this "productA" of "productB". You guessed it, A or B is the id of the store.

For each products in the DB, I will index it n times, where n is the number of available stores that sell this product.

I wanted to use faceting search in order to filter which store I wanted to search on, but I'm in front of a problem:

I'm beginning the indexation and search for "foobar" without faceting the search. I get a list of facets like this:

<lst name="facet_fields">
    <lst name="type">
        <int name="productA">10</int>
        <int>0</int>
</lst>

This number is growing and growing (which is normal) until the indexation of the store A is finished. Then I begin the indexation of store B and get this kind of result when querying solr

<lst name="facet_fields">
    <lst name="type">
        <int name="productA">303</int>
        <int name="productB">6</int>
        <int>0</int>
</lst>

but after a while, solr gets mad and send me this result:

<lst name="facet_fields">
    <lst name="type">
        <int name="productB">320</int>
</lst>

Yes. I don't even got my facet count for productA and I can't even search on it! It will bring 0 results.

Do you have an idea of what's going on? Is using facet for this kind of problem is wrong?


You're probably overwriting documents by unique key. Make sure that the products from different stores have different unique keys. You could do this by appending a prefix per store to the unique key value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜