lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rodrigo Vega (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-4461) Multiple FacetRequest with the same path creates inconsistent results
Date Tue, 09 Oct 2012 11:44:02 GMT

    [ 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


Mime
View raw message