How to implement Solr's facet.missing=true with Lucene
up vote
0
down vote
favorite
Solr supports returning the number of matching documents with no facet value for the field. How can the same be achieved with Lucene?
Example: I have 5 documents that may have values for the a field category
- Document 1 has
category=A
- Document 2 has
category=Aandcategory=B
- Document 3 has
category=Bandcategory=C
- Document 4 and 5 have no
categoryvalues
The code looks like
var facetsCollector = new FacetsCollector();
FacetsCollector.Search(_indexSearcher, new MatchAllDocsQuery(), 100, facetsCollector);
var state = DefaultSortedSetDocValuesReaderState(_indexReader, "category_facet");
var facets = SortedSetDocValuesFacetCounts(state, facetsCollector);
var children = facets.GetTopChildren(100, "category_dim");
This gives me LabelValues
- Label:A, Value:2
- Label:B, Value:2
- Label:C, Value:1
How can I determine "Label:(missing), Value:2"?
Running another query +*:* -category:* is an obvious option. However, can it be done in a smarter way?
lucene facet
add a comment |
up vote
0
down vote
favorite
Solr supports returning the number of matching documents with no facet value for the field. How can the same be achieved with Lucene?
Example: I have 5 documents that may have values for the a field category
- Document 1 has
category=A
- Document 2 has
category=Aandcategory=B
- Document 3 has
category=Bandcategory=C
- Document 4 and 5 have no
categoryvalues
The code looks like
var facetsCollector = new FacetsCollector();
FacetsCollector.Search(_indexSearcher, new MatchAllDocsQuery(), 100, facetsCollector);
var state = DefaultSortedSetDocValuesReaderState(_indexReader, "category_facet");
var facets = SortedSetDocValuesFacetCounts(state, facetsCollector);
var children = facets.GetTopChildren(100, "category_dim");
This gives me LabelValues
- Label:A, Value:2
- Label:B, Value:2
- Label:C, Value:1
How can I determine "Label:(missing), Value:2"?
Running another query +*:* -category:* is an obvious option. However, can it be done in a smarter way?
lucene facet
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Solr supports returning the number of matching documents with no facet value for the field. How can the same be achieved with Lucene?
Example: I have 5 documents that may have values for the a field category
- Document 1 has
category=A
- Document 2 has
category=Aandcategory=B
- Document 3 has
category=Bandcategory=C
- Document 4 and 5 have no
categoryvalues
The code looks like
var facetsCollector = new FacetsCollector();
FacetsCollector.Search(_indexSearcher, new MatchAllDocsQuery(), 100, facetsCollector);
var state = DefaultSortedSetDocValuesReaderState(_indexReader, "category_facet");
var facets = SortedSetDocValuesFacetCounts(state, facetsCollector);
var children = facets.GetTopChildren(100, "category_dim");
This gives me LabelValues
- Label:A, Value:2
- Label:B, Value:2
- Label:C, Value:1
How can I determine "Label:(missing), Value:2"?
Running another query +*:* -category:* is an obvious option. However, can it be done in a smarter way?
lucene facet
Solr supports returning the number of matching documents with no facet value for the field. How can the same be achieved with Lucene?
Example: I have 5 documents that may have values for the a field category
- Document 1 has
category=A
- Document 2 has
category=Aandcategory=B
- Document 3 has
category=Bandcategory=C
- Document 4 and 5 have no
categoryvalues
The code looks like
var facetsCollector = new FacetsCollector();
FacetsCollector.Search(_indexSearcher, new MatchAllDocsQuery(), 100, facetsCollector);
var state = DefaultSortedSetDocValuesReaderState(_indexReader, "category_facet");
var facets = SortedSetDocValuesFacetCounts(state, facetsCollector);
var children = facets.GetTopChildren(100, "category_dim");
This gives me LabelValues
- Label:A, Value:2
- Label:B, Value:2
- Label:C, Value:1
How can I determine "Label:(missing), Value:2"?
Running another query +*:* -category:* is an obvious option. However, can it be done in a smarter way?
lucene facet
lucene facet
asked Nov 19 at 12:19
Paul B.
1,7201839
1,7201839
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374492%2fhow-to-implement-solrs-facet-missing-true-with-lucene%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown