You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Kyle Maxwell (JIRA)" <ji...@apache.org> on 2007/10/05 03:06:50 UTC

[jira] Created: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

CustomScoreQuery should support multiple ValueSourceQueries
-----------------------------------------------------------

                 Key: LUCENE-1019
                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
             Project: Lucene - Java
          Issue Type: Improvement
          Components: Search
    Affects Versions: 2.2
            Reporter: Kyle Maxwell


CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.

This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.

This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12547673 ] 

Doron Cohen commented on LUCENE-1019:
-------------------------------------

{quote}
    * The way in which caching is handled is now unclear.
{quote}

For e.g. IntFieldSource caching is done in that level, so I am not sure 
I understand about what is unclear here.

{quote}
    *  Trying to get explain information from the sub-ValueSources was quite difficult.
    * There is much more code in my queries, leading to increased brittleness.
{quote}

Yes I agree about this part.
I had the similar experience when combining field values, and decided to just live with that. 
In a glance, the v2 patch seems to solve this nicely so I will look into committing this.

Thanks for bringing this up,
Doron

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549016 ] 

Doron Cohen commented on LUCENE-1019:
-------------------------------------

When working on this I hoped that Solr would move to
use it, but by SOLR-192 it never happen. If someone in
Solr is committed to do this I will definitely work on it
(hoping there's nothing with the ne functionality in Solr
that breaks with our changes so far). I will ask in Solr.

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>            Priority: Minor
>             Fix For: 2.3
>
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff, lucene-1019-multi-vsq.patch
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532789 ] 

fizx edited comment on LUCENE-1019 at 10/5/07 3:36 PM:
---------------------------------------------------------------

Here's a slightly simpler version of the diff (v1).

The default behavior of CustomScoreQuery with multiple ValueSourceQueries does not matter to me.  I really want to be able to override it with custom logic.  Also note that multiplying twice is currently as simple as CustomScoreQuery(CustomScoreQuery(subQuery, value1), value2).  But what about things that aren't linear combinations?

Use case:  I want the score to fall off exponentially as content ages, with a decay rate that varies on a per document basis.  

Each document has three fields: "text," "created-at," and "half-life."  Created-at is represented as a UNIX timestamp, and half-life in seconds.  I'm not sure that the following query is able to be expressed as nested queries.  There may be another way to do this, but this seems simple and elegant to me.

{code:java}
public class DateDecayQuery extends CustomScoreQuery {
	public final double LOG2 = Math.log(2);
	private long now;

	public DateDecayQuery(Query subQuery) {
		super(subQuery, new ValueSourceQuery[] {
				new FieldScoreQuery("created-at", Type.INT),
				new FieldScoreQuery("half-life", Type.INT) });
		now = new Date().getTime() / 1000; // UNIX timestamp;
		setStrict(true);
	}

	public float customScore(int doc, float score, float fields[]) {
		float date = fields[0];
		float halfLife = fields[1];
		float dateScore = (float) Math.exp(LOG2 * (date - now) / halfLife);
		return score * dateScore;
	}
}
{code}

      was (Author: fizx):
    Here's a slightly simpler version of the diff (v1).

The default behavior of CustomScoreQuery with multiple ValueSourceQueries does not matter to me.  I really want to be able to override it with custom logic.  Also note that multiplying twice is currently as simple as CustomScoreQuery(CustomScoreQuery(subQuery, value1), value2).  But what about things that aren't linear combinations?

Use case:  I want the score to fall off exponentially as content ages, with a decay rate that varies on a per document basis.  

Each document has three fields: "text," "created-at," and "half-life."  Created-at is represented as a UNIX timestamp, and half-life in seconds.  I'm not sure that the following query is able to be expressed as nested queries.  There may be another way to do this, but this seems simple and elegant to me.

{code:java}
public class DateDecayQuery extends CustomScoreQuery {
	public final double LOG2 = Math.log(2);
	private long now;

	public DateDecayQuery(Query subQuery) {
		super(subQuery, new ValueSourceQuery[] {
				new FieldScoreQuery("date", Type.INT),
				new FieldScoreQuery("half-life", Type.INT) });
		now = new Date().getTime() / 1000; // UNIX timestamp;
		setStrict(true);
	}

	public float customScore(int doc, float score, float fields[]) {
		float date = fields[0];
		float halfLife = fields[1];
		float dateScore = (float) Math.exp(LOG2 * (date - now) / halfLife);
		return score * dateScore;
	}
}
{code}
  
> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen resolved LUCENE-1019.
---------------------------------

    Resolution: Fixed

Committed, thanks Kyle!

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>            Priority: Minor
>             Fix For: 2.3
>
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff, lucene-1019-multi-vsq.patch
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Maxwell updated LUCENE-1019:
---------------------------------

    Attachment: CustomMultiQuery.v0.diff

Here's the patch!

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Closed: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Maxwell closed LUCENE-1019.
--------------------------------

       Resolution: Invalid
    Lucene Fields:   (was: [Patch Available, New])

Ok, I'm satisfied with Doron's solution.  It'd be nice to see something like this in some documentation, somewhere.  The wiki is prolly appropriate.

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534038 ] 

Doron Cohen commented on LUCENE-1019:
-------------------------------------

You could put this logic in your implementation of ValueSource, 
possibly constructed over multiple FieldCacheSources - 

{code:title=DateDecayQuery over multiple value sources}
public class DateDecayQuery extends CustomScoreQuery {

  public DateDecayQuery(Query subQuery) {
    super(subQuery, createValSrceQuery());
    setStrict(true);
  }

  private static ValueSourceQuery createValSrceQuery() {
    return new ValueSourceQuery(new HalfLifeValSrc());
  }
  
  private static class HalfLifeValSrc extends ValueSource {
    final ValueSource createdAt  = new IntFieldSource("created-at");
    final ValueSource halfLife  = new IntFieldSource("half-life");
    final long now = new Date().getTime() / 1000; // UNIX timestamp;
    final double LOG2 = Math.log(2);

    public DocValues getValues(final IndexReader reader) throws IOException {
      final DocValues valsCreated = createdAt.getValues(reader);
      final DocValues valsHalfLife = halfLife.getValues(reader);
      return new DocValues(reader.maxDoc()) {
        public float floatVal(int doc) {
          float vCreated = valsCreated.floatVal(doc);
          float vHalfLife = valsHalfLife.floatVal(doc);
          return (float) Math.exp(LOG2 * (vCreated - now) / vHalfLife);
        }
      };
    }
  }
}
{code}

Though usage is much simpler if this is added to the query.


> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Hoss Man (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532560 ] 

Hoss Man commented on LUCENE-1019:
----------------------------------

this class seems to assume that the ValueSourceQueries should be multipled ... but it would be just as easy to assume the should be added, or averaged.

It seems like it might make more sense if instead of a CustomMultiScoreQuery there was just a "ProductValueSource" class that took in a ValueSource[] and multiplied them

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Assigned: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen reassigned LUCENE-1019:
-----------------------------------

    Assignee: Doron Cohen

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Maxwell updated LUCENE-1019:
---------------------------------

    Attachment: CustomScoreQuery.v1.diff

Here's a slightly simpler version of the diff (v1).

The default behavior of CustomScoreQuery with multiple ValueSourceQueries does not matter to me.  I really want to be able to override it with custom logic.  Also note that multiplying twice is currently as simple as CustomScoreQuery(CustomScoreQuery(subQuery, value1), value2).  But what about things that aren't linear combinations?

Use case:  I want the score to fall off exponentially as content ages, with a decay rate that varies on a per document basis.  

Each document has three fields: "text," "created-at," and "half-life."  Created-at is represented as a UNIX timestamp, and half-life in seconds.  I'm not sure that the following query is able to be expressed as nested queries.  There may be another way to do this, but this seems simple and elegant to me.

{code:java}
public class DateDecayQuery extends CustomScoreQuery {
	public final double LOG2 = Math.log(2);
	private long now;

	public DateDecayQuery(Query subQuery) {
		super(subQuery, new ValueSourceQuery[] {
				new FieldScoreQuery("date", Type.INT),
				new FieldScoreQuery("half-life", Type.INT) });
		now = new Date().getTime() / 1000; // UNIX timestamp;
		setStrict(true);
	}

	public float customScore(int doc, float score, float fields[]) {
		float date = fields[0];
		float halfLife = fields[1];
		float dateScore = (float) Math.exp(LOG2 * (date - now) / halfLife);
		return score * dateScore;
	}
}
{code}

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen updated LUCENE-1019:
--------------------------------

    Attachment: lucene-1019-multi-vsq.patch

lucene-1019-multi-vsq.patch:
* modified version2: 
** fixed hash() and equals()
** added a multi vsq form of customExplain()
** more documentation in customScore() and customExplain()
** added test of multi vsq
* fixed a bug in search.function tests

All tests pass. 
I intend to commit this in a few days. 

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff, lucene-1019-multi-vsq.patch
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532557 ] 

fizx edited comment on LUCENE-1019 at 10/4/07 6:08 PM:
---------------------------------------------------------------

Here's the patch!  BTW, I'll edit the docs as soon as someone signs off that this is a good idea!

      was (Author: fizx):
    Here's the patch!
  
> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen updated LUCENE-1019:
--------------------------------

    Fix Version/s: 2.3
         Priority: Minor  (was: Major)
    Lucene Fields: [Patch Available]  (was: [Patch Available, New])

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>            Priority: Minor
>             Fix For: 2.3
>
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff, lucene-1019-multi-vsq.patch
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Reopened: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Kyle Maxwell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Maxwell reopened LUCENE-1019:
----------------------------------

    Lucene Fields: [New, Patch Available]

Hi, after trying out the combined valuesource implementation suggested by Doron, I've found it to be _extremely_ cumbersome and brittle in practice.  Therefore, I am reopening this ticket.  

- Trying to get explain information from the sub-ValueSources was quite difficult.
- There is much more code in my queries, leading to increased brittleness.
- The way in which caching is handled is now unclear.

Can this ticket please be reconsidered?  Thanks!

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1019) CustomScoreQuery should support multiple ValueSourceQueries

Posted by "Grant Ingersoll (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549007 ] 

Grant Ingersoll commented on LUCENE-1019:
-----------------------------------------

Somewhat related, but any thoughts on some of the newer functionality in Solr?  I really hate to see such a divergence.

> CustomScoreQuery should support multiple ValueSourceQueries
> -----------------------------------------------------------
>
>                 Key: LUCENE-1019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1019
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 2.2
>            Reporter: Kyle Maxwell
>            Assignee: Doron Cohen
>            Priority: Minor
>             Fix For: 2.3
>
>         Attachments: CustomMultiQuery.v0.diff, CustomScoreQuery.v1.diff, lucene-1019-multi-vsq.patch
>
>
> CustomScoreQuery's constructor currently accepts a subQuery, and a ValueSourceQuery.  I would like it to accept multiple ValueSourceQueries.  The workaround of nested CustomScoreQueries works for simple cases, but it quickly becomes either cumbersome to manage, or impossible to implement the desired function.
> This patch implements CustomMultiScoreQuery with my desired functionality, and refactors CustomScoreQuery to implement the special case of a CustomMultiScoreQuery with 0 or 1 ValueSourceQueries.  This keeps the CustomScoreQuery API intact.
> This patch includes basic tests, more or less taken from the original implementation, and customized a bit to cover the new cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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