Hi,

Also I noticed that in your code snippet you have server.delete("foo"); which 
does not exists. deleteById and deleteByQuery methods are defined in SolrServer 
implementation.



On Monday, February 17, 2014 1:42 PM, Ahmet Arslan <iori...@yahoo.com> wrote:
Hi Marius,

Facets are computed from indexed terms. Can you commit with expungeDeletes=true 
flag?

Ahmet




On Monday, February 17, 2014 12:17 PM, Marius Dumitru Florea 
<mariusdumitru.flo...@xwiki.com> wrote:
Hi guys,

I'm using Solr 4.6.1 (embedded) and for some reason the facet cache is
not invalidated when documents are deleted from the index. Sadly, for
me, I cannot reproduce this issue with an integration test like this:

----------8<----------
SolrInstance server = getSolrInstance();

SolrInputDocument document = new SolrInputDocument();
document.setField("id", "foo");
document.setField("locale", "en");
server.add(document);

server.commit();

document = new SolrInputDocument();
document.setField("id", "bar");
document.setField("locale", "en");
server.add(document);

server.commit();

SolrQuery query = new SolrQuery("*:*");
query.set("facet", "on");
query.set("facet.field", "locale");
QueryResponse response = server.query(query);

Assert.assertEquals(2, response.getResults().size());
FacetField localeFacet = response.getFacetField("locale");
Assert.assertEquals(1, localeFacet.getValues().size());
Count en = localeFacet.getValues().get(0);
Assert.assertEquals("en", en.getName());
Assert.assertEquals(2, en.getCount());

server.delete("foo");
server.commit();

response = server.query(query);

Assert.assertEquals(1, response.getResults().size());
localeFacet = response.getFacetField("locale");
Assert.assertEquals(1, localeFacet.getValues().size());
en = localeFacet.getValues().get(0);
Assert.assertEquals("en", en.getName());
Assert.assertEquals(1, en.getCount());
---------->8----------

Nevertheless, when I do the 'same' on my real environment, the count
for the locale facet remains 2 after one of the documents is deleted.
The search result count is fine, so that's why I think it's a facet
cache issue. Note that the facet count remains 2 even after I restart
the server, so the cache is persisted on the file system.

Strangely, the facet count is updated correctly if I modify the
document instead of deleting it (i.e. removing a keyword from the
content so that it isn't matched by the search query any more). So it
looks like only delete triggers the issue.

Now, an interesting fact is that if, on my real environment, I delete
one of the documents and then add a new one, the facet count becomes
3. So the last commit to the index, which inserts a new document,
doesn't trigger a re-computation of the facet cache. The previous
facet cache is simply incremented, so the error is perpetuated. At
this point I don't even know how to fix the facet cache without
deleting the Solr data folder so that the full index is rebuild.

I'm still trying to figure out what is the difference between the
integration test and my real environment (as I used the same schema
and configuration). Do you know what might be wrong?

Thanks,
Marius

Reply via email to