You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Vjeran Marcinko <vm...@gmail.com> on 2017/08/30 18:37:29 UTC

Document updating and SortedSetDocValuesFacetField

?Hi everyone,

Short question is: How do one update document that already has some
SortedSetDocValuesFacetFields?

Longer story is here...

I'm using SortedSetDocValuesFacetField and faceting feature to
implement "count by group" and everything works fine when I store the
document for first time, such as:
indexWriter.addDocument(facetConfig.build(document));
 and later query these "group counts" using FacetCollector and
SortedSetDocValuesFacetCounts.

BUT, later when I read those stored documents, and update these
documents in index (because I added some additional fields to them):

indexWriter.updateDocument(term, document);
or even using facetConfig again...
indexWriter.updateDocument(term, facetConfig.build(document));

Then it seems that these faceting/docValued field information is no
longer there or whatever, because my querying for "group counts"
doesn't take these documents into account. And if I update all
documents in index in described way, then it seems this whole faceted
field is no longer there because I get following when trying to
collect these "group counts":

Exception in thread "main" java.lang.IllegalArgumentException: field
"facet_category" was not indexed with SortedSetDocValues
at org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState.<init>(DefaultSortedSetDocValuesReaderState.java:72)
...
...

Regards,
Vjeran

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Document updating and SortedSetDocValuesFacetField

Posted by Bryan Bende <bb...@apache.org>.
I came across this same exception when I performed a query that faceted on a field that had no documents in the index with that field. One simple case was attempting to perform faceting on an empty index.

Is it possible that no documents in your index have a value for "facet_category" at the time you are attempting to facet?

For now I only create the  DefaultSortedSetDocValuesReaderState if facetsCollector.getMatchingDocs().size() > 0 which protects against the case where in the index is empty, but it doesn't work if there were docs matching a different field.

On 2017-08-30 14:37, Vjeran Marcinko <vm...@gmail.com> wrote: 
> ?Hi everyone,
> 
> Short question is: How do one update document that already has some
> SortedSetDocValuesFacetFields?
> 
> Longer story is here...
> 
> I'm using SortedSetDocValuesFacetField and faceting feature to
> implement "count by group" and everything works fine when I store the
> document for first time, such as:
> indexWriter.addDocument(facetConfig.build(document));
>  and later query these "group counts" using FacetCollector and
> SortedSetDocValuesFacetCounts.
> 
> BUT, later when I read those stored documents, and update these
> documents in index (because I added some additional fields to them):
> 
> indexWriter.updateDocument(term, document);
> or even using facetConfig again...
> indexWriter.updateDocument(term, facetConfig.build(document));
> 
> Then it seems that these faceting/docValued field information is no
> longer there or whatever, because my querying for "group counts"
> doesn't take these documents into account. And if I update all
> documents in index in described way, then it seems this whole faceted
> field is no longer there because I get following when trying to
> collect these "group counts":
> 
> Exception in thread "main" java.lang.IllegalArgumentException: field
> "facet_category" was not indexed with SortedSetDocValues
> at org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState.<init>(DefaultSortedSetDocValuesReaderState.java:72)
> ...
> ...
> 
> Regards,
> Vjeran
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org