You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Robert Muir (JIRA)" <ji...@apache.org> on 2010/11/11 14:46:13 UTC

[jira] Created: (LUCENE-2754) add spanquery support for all multitermqueries

add spanquery support for all multitermqueries
----------------------------------------------

                 Key: LUCENE-2754
                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
             Project: Lucene - Java
          Issue Type: New Feature
          Components: Search
            Reporter: Robert Muir
             Fix For: 4.0
         Attachments: LUCENE-2754.patch

I set fix version: 4.0, but possibly we could do this for 3.x too

Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
The SpanRegexQuery in contrib is a little messy additionally.

For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
# The un-rewritten query must extend SpanQuery so it can be included in Span clauses
# The rewritten query should be SpanOrQuery instead of BooleanQuery
# The rewritten term clauses should be SpanTermQueries.

Instead of having logic like this for each query, i suggest adding two rewrite methods:
* ScoringSpanBoolean rewrite
* TopTermsSpanBoolean rewrite

as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
there are a few kinks, but I think the MTQ policeman can probably help get through them.


-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Updated: (LUCENE-2754) add spanquery support for all multitermqueries

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

Robert Muir updated LUCENE-2754:
--------------------------------

    Attachment: LUCENE-2754.patch

Attached is an improved patch, still not perfect but better.

I added Uwe's suggestion of delegating all methods in the wrapper, and also
setting the rewrite method in the ctor and documenting that it does this.

I added a simple test case in search.spans that wraps some wildcard and fuzzy queries,
and added examples and javadocs.

I also deprecated the SpanRegexQuery, converted the tests for the contrib SpanRegexQuery to use the wrapper directly, and deprecated the old tests, but they still work too.

I would prefer to avoid the heavy refactoring of MultiTermQuery rewrites (easier on another issue?) just because it would make backporting to 3.x a little more tricky.

Anyway, I think this is pretty close, maybe just needs another police investigation
before committing.


> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch, LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-2754) add spanquery support for all multitermqueries

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

Uwe Schindler resolved LUCENE-2754.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 3.1

Committed 3.x revision: 1035118

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 3.1, 4.0
>
>         Attachments: LUCENE-2754.patch, LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931041#action_12931041 ] 

Uwe Schindler commented on LUCENE-2754:
---------------------------------------

What about the third BQ rewrite mode (is it needed or is scoring different (we have two rerwite modes for fuzzy)?

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Updated: (LUCENE-2754) add spanquery support for all multitermqueries

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

Robert Muir updated LUCENE-2754:
--------------------------------

    Attachment: LUCENE-2754.patch

here's an initial patch... all the SpanRegexQuery tests pass, but it could use its own tests too.

theres a nocommit mentioning what i don't like.


> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931053#action_12931053 ] 

Uwe Schindler commented on LUCENE-2754:
---------------------------------------

bq. When we respect both things, why do we need the wrapper at all

Ah because query must extend SpanQuery :-) That solves my problem.

So the rewrite methods can only be used for real SpanQueries, how about moving those rewrite methods out of MTQ? I know, then we must make some classes more public... But I was already thinking about the code mess in MTQ. Maybe we should remove those modes and put into separate classes at all.

+1 to backport to 3.x

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931919#action_12931919 ] 

Uwe Schindler commented on LUCENE-2754:
---------------------------------------

Committed trunk revision: 1035096

Now backporting...

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch, LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931700#action_12931700 ] 

Uwe Schindler commented on LUCENE-2754:
---------------------------------------

The linked  LUCENE-2757 will add support for this while also refactoring MTQ.

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch, LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Robert Muir (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931070#action_12931070 ] 

Robert Muir commented on LUCENE-2754:
-------------------------------------

bq. What about the third BQ rewrite mode (is it needed or is scoring different (we have two rerwite modes for fuzzy)?

In this case, i thought not because it would be constant score queries, not spanqueries.
I think a constant score spanquery would be useless :)

{quote}
So the rewrite methods can only be used for real SpanQueries, how about moving those rewrite methods out of MTQ? I know, then we must make some classes more public... But I was already thinking about the code mess in MTQ. Maybe we should remove those modes and put into separate classes at all.
{quote}

I agree completely... its tricky to scroll through the massive .java file and find what we want. 
I would also prefer in this case for the Span-rewrite methods to be in the actual o.a.l.search.span package...


> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2754) add spanquery support for all multitermqueries

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931040#action_12931040 ] 

Uwe Schindler commented on LUCENE-2754:
---------------------------------------

Looks good, even the generics policeman is happy (with the wrapper which is like MTQWrapperFilter! Phantastic :-)

About the nocommit and more problems related to this:

- I would remove separate boosts for wrapped and wrapper query. The wrapper should simply delegate get/setBoost(). We have other examples in Lucene that do the same (somewhere...). So the boost does not need to be set in rewrite() and toString() may not show two different boosts. toString() should not print any boost at all (only the wrapped query will do).
- The same should be done in the rewrite method, it should simply delegate. In ctor, it could set the rewrite mode initially to a span default. We should only document this.

When we respect both things, why do we need the wrapper at all? Wrapping and setting a rewrite mode is the same work. And the SpanRegExQuery in contrib could simply set the rewrite mode in the ctor (like Fuzzy or NRQ does) and maybe override toString() for nice output.

> add spanquery support for all multitermqueries
> ----------------------------------------------
>
>                 Key: LUCENE-2754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2754
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Search
>            Reporter: Robert Muir
>             Fix For: 4.0
>
>         Attachments: LUCENE-2754.patch
>
>
> I set fix version: 4.0, but possibly we could do this for 3.x too
> Currently, we have a special SpanRegexQuery in contrib, and issues like LUCENE-522 open for SpanFuzzyQuery.
> The SpanRegexQuery in contrib is a little messy additionally.
> For any arbitrary MultiTermQueries to work as a SpanQuery, there are only 3 requirements:
> # The un-rewritten query must extend SpanQuery so it can be included in Span clauses
> # The rewritten query should be SpanOrQuery instead of BooleanQuery
> # The rewritten term clauses should be SpanTermQueries.
> Instead of having logic like this for each query, i suggest adding two rewrite methods:
> * ScoringSpanBoolean rewrite
> * TopTermsSpanBoolean rewrite
> as a start i wrote these up, and added a SpanMultiTermQueryWrapper that can be used to wrap any multitermquery this way.
> there are a few kinks, but I think the MTQ policeman can probably help get through them.

-- 
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org