You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Rodrigo Vega (JIRA)" <ji...@apache.org> on 2012/10/05 17:22:04 UTC
[jira] [Created] (LUCENE-4461) Multiple FacetRequest with the same
path creates inconsistent results
Rodrigo Vega created LUCENE-4461:
------------------------------------
Summary: Multiple FacetRequest with the same path creates inconsistent results
Key: LUCENE-4461
URL: https://issues.apache.org/jira/browse/LUCENE-4461
Project: Lucene - Core
Issue Type: Bug
Components: modules/facet
Affects Versions: 3.6
Reporter: Rodrigo Vega
Multiple FacetRequest are getting merged into one creating wrong results in this case:
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
Problem can be fixed defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
A Very simple test case:
========================
public class LuceneFacetTest {
@Test
public void testDuplicateFacetRequest() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)));
Directory taxoDir = new RAMDirectory();
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
Document doc = new Document();
doc.add(new Field("title", "simple text title", Store.YES, org.apache.lucene.document.Field.Index.ANALYZED));
List<CategoryPath> categories = new ArrayList<CategoryPath>();
categories.add(new CategoryPath("author", "Mark Twain"));
categories.add(new CategoryPath("year", "2010"));
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxoWriter);
categoryDocBuilder.setCategoryPaths(categories);
categoryDocBuilder.build(doc);
writer.addDocument(doc);
writer.commit();
taxoWriter.commit();
IndexReader indexReader = IndexReader.open(writer, true);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
Query q = new TermQuery(new Term("title", "text"));
TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
searcher.search(q, MultiCollector.wrap(tdc, facetsCollector));
List<FacetResult> res = facetsCollector.getFacetResults();
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(0).getNumValidDescendants());
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(1).getNumValidDescendants());
}
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472280#comment-13472280 ]
Rodrigo Vega commented on LUCENE-4461:
--------------------------------------
In my case the final user can specify his/her default query to show once he/she is logged into the system. This issue came up when somebody define the same facet request using one as filter and the other only as a pure count request.
I did not find a clean way to fix it looking through the code, but i'm trying the current "ugly" solution where "counter" is the request index.
{code}
public class CustomCountFacetRequest extends CountFacetRequest {
private int hashCode;
public CustomCountFacetRequest(CategoryPath path, int num) {
this(path, num, 0);
}
public CustomCountFacetRequest(CategoryPath path, int num, int counter) {
super(path, num);
hashCode = super.hashCode() * counter;
}
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object o) {
if (o instanceof CustomCountFacetRequest) {
CustomCountFacetRequest that = (CustomCountFacetRequest) o;
return that.hashCode == this.hashCode && super.equals(o);
}
return false;
}
}
{code}
I didn't find collateral effects on this solution yet, however i'm worried with your comments about breaking other parts of the code.
I'm not sure if throwing an exception is the best solution, but at least the response will be consistent.
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Gilad Barkai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472416#comment-13472416 ]
Gilad Barkai commented on LUCENE-4461:
--------------------------------------
The same category can be set as a filter and as a request without them colliding - a filter is correlated or dependent on a facet request.
facets filters are done at the query level which affects the result set, while the facetRequest defines which categories to retrieve out of the result set.
I probably miss something here :)
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Updated] (LUCENE-4461) Multiple FacetRequest with the same
path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rodrigo Vega updated LUCENE-4461:
---------------------------------
Attachment: LuceneFacetTest.java
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Gilad Barkai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472437#comment-13472437 ]
Gilad Barkai commented on LUCENE-4461:
--------------------------------------
Well solve you code issues no :) But the current code is indeed broken by the issue you raised - and that should be fixed.
I re examined the code, and I think the different hashcode you presented will work - though please note it will consume some extra CPU, as the same request will be handled twice (that's the heap to figure out the top-k of the request) to create separate FacetResults for each request.
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Gilad Barkai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472164#comment-13472164 ]
Gilad Barkai commented on LUCENE-4461:
--------------------------------------
Nice catch!
Took a while to pinpoint the reason - lines 173-181 of StandardFacetsAccumulator.
In the mentioned lines, a 'merge' is performed over categories which matched the request, but reside on different partitions.
bq. Partitions are an optimization which limit the RAM requirements per query to a constant, rather than linear to the taxonomy size (could be millions of categories). The taxonomy is virtually "splitted" into partitions of constant size, a top-k is heaped from each partition, and all those top-k results are being merged to a global top-k list
The proposed solution of changing the hashCode and equals so that the same request will have two hashCodes and will not be equal to itself is very likely to break other parts of the code.
Perhaps such cases could be prevented all together? e.g throwing an exception when the (exact) same request is added twice.
Is that a reasonable solution? Are there cases where it is necessary to request the same path twice?
Please note that a different count, depth, path etc - makes a different request, so requesting "author" with count 10 and count 11 makes different requests - which are handled simultaneously correctly in current versions.
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472443#comment-13472443 ]
Rodrigo Vega commented on LUCENE-4461:
--------------------------------------
I though there is any kind of cache to avoid doing same work twice or at least some part of it. However I think that is a different issue/feature/discussion. Thanks for your time.
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the
same path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472429#comment-13472429 ]
Rodrigo Vega commented on LUCENE-4461:
--------------------------------------
Yes, I know that but i need a generic way to handle the facet requests during search preparation stage. For that reason I have a FacetParams object with the following properties: int limit, String[] path, boolean filter
Then I can have some peace of code like this:
{code}
// Query is a bean that wraps a lucene query just to make easy the integration with our UI. REal lucene query is // handle by "q"
if (query.isFaceted())
for (FacetParams facet : query.getFacet()) {
CategoryPath c = new CategoryPath(facet.getPath());
facetSearchParams.addFacetRequest(new CountFacetRequest(c, facet.getLimit()));
if (facet.isFilter())
q = DrillDown.query(q, c);
}
... preapre collectors and finally search
{code}
This is because the user can create its own query using some kind of wizard. So I have two options:
* Support this feature
* Avoid configurations with this kind of cases.
It is not a really big problem it is mostly about how to keep my code as neat as I can :) . I can't ask you to solve my code issues :D
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Updated] (LUCENE-4461) Multiple FacetRequest with the same
path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rodrigo Vega updated LUCENE-4461:
---------------------------------
Description:
Multiple FacetRequest are getting merged into one creating wrong results in this case:
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
Attached test case.
was:
Multiple FacetRequest are getting merged into one creating wrong results in this case:
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
A Very simple test case:
========================
public class LuceneFacetTest {
@Test
public void testDuplicateFacetRequest() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)));
Directory taxoDir = new RAMDirectory();
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
Document doc = new Document();
doc.add(new Field("title", "simple text title", Store.YES, org.apache.lucene.document.Field.Index.ANALYZED));
List<CategoryPath> categories = new ArrayList<CategoryPath>();
categories.add(new CategoryPath("author", "Mark Twain"));
categories.add(new CategoryPath("year", "2010"));
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxoWriter);
categoryDocBuilder.setCategoryPaths(categories);
categoryDocBuilder.build(doc);
writer.addDocument(doc);
writer.commit();
taxoWriter.commit();
IndexReader indexReader = IndexReader.open(writer, true);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
Query q = new TermQuery(new Term("title", "text"));
TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
searcher.search(q, MultiCollector.wrap(tdc, facetsCollector));
List<FacetResult> res = facetsCollector.getFacetResults();
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(0).getNumValidDescendants());
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(1).getNumValidDescendants());
}
}
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Comment Edited] (LUCENE-4461) Multiple FacetRequest with
the same path creates inconsistent results
Posted by "Gilad Barkai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472416#comment-13472416 ]
Gilad Barkai edited comment on LUCENE-4461 at 10/9/12 2:16 PM:
---------------------------------------------------------------
The same category can be set as a filter and as a request without them colliding - a filter is not correlated or dependent on a facet request.
facets filters are done at the query level which affects the result set, while the facetRequest defines which categories to retrieve out of the result set.
I probably miss something here :)
was (Author: gilad):
The same category can be set as a filter and as a request without them colliding - a filter is correlated or dependent on a facet request.
facets filters are done at the query level which affects the result set, while the facetRequest defines which categories to retrieve out of the result set.
I probably miss something here :)
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> Attached test case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
[jira] [Updated] (LUCENE-4461) Multiple FacetRequest with the same
path creates inconsistent results
Posted by "Rodrigo Vega (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-4461?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rodrigo Vega updated LUCENE-4461:
---------------------------------
Description:
Multiple FacetRequest are getting merged into one creating wrong results in this case:
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
A Very simple test case:
========================
public class LuceneFacetTest {
@Test
public void testDuplicateFacetRequest() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)));
Directory taxoDir = new RAMDirectory();
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
Document doc = new Document();
doc.add(new Field("title", "simple text title", Store.YES, org.apache.lucene.document.Field.Index.ANALYZED));
List<CategoryPath> categories = new ArrayList<CategoryPath>();
categories.add(new CategoryPath("author", "Mark Twain"));
categories.add(new CategoryPath("year", "2010"));
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxoWriter);
categoryDocBuilder.setCategoryPaths(categories);
categoryDocBuilder.build(doc);
writer.addDocument(doc);
writer.commit();
taxoWriter.commit();
IndexReader indexReader = IndexReader.open(writer, true);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
Query q = new TermQuery(new Term("title", "text"));
TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
searcher.search(q, MultiCollector.wrap(tdc, facetsCollector));
List<FacetResult> res = facetsCollector.getFacetResults();
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(0).getNumValidDescendants());
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(1).getNumValidDescendants());
}
}
was:
Multiple FacetRequest are getting merged into one creating wrong results in this case:
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
Problem can be fixed defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
A Very simple test case:
========================
public class LuceneFacetTest {
@Test
public void testDuplicateFacetRequest() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)));
Directory taxoDir = new RAMDirectory();
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
Document doc = new Document();
doc.add(new Field("title", "simple text title", Store.YES, org.apache.lucene.document.Field.Index.ANALYZED));
List<CategoryPath> categories = new ArrayList<CategoryPath>();
categories.add(new CategoryPath("author", "Mark Twain"));
categories.add(new CategoryPath("year", "2010"));
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxoWriter);
categoryDocBuilder.setCategoryPaths(categories);
categoryDocBuilder.build(doc);
writer.addDocument(doc);
writer.commit();
taxoWriter.commit();
IndexReader indexReader = IndexReader.open(writer, true);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
Query q = new TermQuery(new Term("title", "text"));
TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
FacetSearchParams facetSearchParams = new FacetSearchParams();
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
searcher.search(q, MultiCollector.wrap(tdc, facetsCollector));
List<FacetResult> res = facetsCollector.getFacetResults();
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(0).getNumValidDescendants());
Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(1).getNumValidDescendants());
}
}
> Multiple FacetRequest with the same path creates inconsistent results
> ---------------------------------------------------------------------
>
> Key: LUCENE-4461
> URL: https://issues.apache.org/jira/browse/LUCENE-4461
> Project: Lucene - Core
> Issue Type: Bug
> Components: modules/facet
> Affects Versions: 3.6
> Reporter: Rodrigo Vega
> Labels: facet, faceted-search
> Attachments: LuceneFacetTest.java
>
>
> Multiple FacetRequest are getting merged into one creating wrong results in this case:
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> Problem can be fixed by defining hashcode and equals in certain way that Lucene recognize we are talking about different requests.
> A Very simple test case:
> ========================
> public class LuceneFacetTest {
> @Test
> public void testDuplicateFacetRequest() throws Exception {
> IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)));
> Directory taxoDir = new RAMDirectory();
> TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
> Document doc = new Document();
> doc.add(new Field("title", "simple text title", Store.YES, org.apache.lucene.document.Field.Index.ANALYZED));
> List<CategoryPath> categories = new ArrayList<CategoryPath>();
> categories.add(new CategoryPath("author", "Mark Twain"));
> categories.add(new CategoryPath("year", "2010"));
> CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxoWriter);
> categoryDocBuilder.setCategoryPaths(categories);
> categoryDocBuilder.build(doc);
> writer.addDocument(doc);
> writer.commit();
> taxoWriter.commit();
> IndexReader indexReader = IndexReader.open(writer, true);
> IndexSearcher searcher = new IndexSearcher(indexReader);
> TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
> Query q = new TermQuery(new Term("title", "text"));
> TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
> FacetSearchParams facetSearchParams = new FacetSearchParams();
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("author"), 10));
> FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
> searcher.search(q, MultiCollector.wrap(tdc, facetsCollector));
> List<FacetResult> res = facetsCollector.getFacetResults();
> Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(0).getNumValidDescendants());
> Assert.assertEquals("Only Mark Twain should be returned as result", 1, res.get(1).getNumValidDescendants());
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org