You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Adrien Grand (JIRA)" <ji...@apache.org> on 2016/10/07 08:47:21 UTC

[jira] [Commented] (LUCENE-7481) SpanPayloadCheckQuery is missing rewrite method

    [ https://issues.apache.org/jira/browse/LUCENE-7481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15554557#comment-15554557 ] 

Adrien Grand commented on LUCENE-7481:
--------------------------------------

You are right, it should rewrite the inner query. Would you like to work on a patch?

> SpanPayloadCheckQuery is missing rewrite method
> -----------------------------------------------
>
>                 Key: LUCENE-7481
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7481
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 6.x
>            Reporter: Roman Chyla
>
> If used with a wildcard query, the result is a failure saying: "Rewrite query first"
> The SpanNearQuery has the rewrite method; however the SpanPayloadCheckQuery just returns the query itself. 
> this works:
> ```
> spanNear([vectrfield:ebyuugz, SpanMultiTermQueryWrapper(vectrfield:e*), SpanMultiTermQueryWrapper(vectrfield:m*), SpanMultiTermQueryWrapper(vectrfield:f*)], 0, true)
> ```
> code to generate the query:
> ```
> private Query getSpanQuery(String[] parts, int howMany, boolean truncate) throws UnsupportedEncodingException {
> 		SpanQuery[] clauses = new SpanQuery[howMany+1];
> 		clauses[0] = new SpanTermQuery(new Term("vectrfield", parts[0])); // surname
> 		for (int i = 0; i < howMany; i++) {
> 			if (truncate) {
> 			  SpanMultiTermQueryWrapper<WildcardQuery> q = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("vectrfield", parts[i+1].substring(0, 1) + "*")));
> 				clauses[i+1] = q;
> 			}
> 			else {
> 				clauses[i+1] = new SpanTermQuery(new Term("vectrfield", parts[i+1]));
> 			}
> 		}
> 		SpanNearQuery sq = new SpanNearQuery(clauses, 0, true); // match in order
> 		return sq;
> 	}
> ```
> and this fails:
> ```
> spanPayCheck(spanNear([vectrfield:ebyuugz, SpanMultiTermQueryWrapper(vectrfield:e*), SpanMultiTermQueryWrapper(vectrfield:m*), SpanMultiTermQueryWrapper(vectrfield:f*)], 1, true), payloadRef: 0;1;2;3;)
> ```
> each clause is made of:
> ```
> new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("vectrfield", parts[i+1].substring(0, 1) + "*")));
> ```
> It is a regression; the code was working well in SOLR4.x



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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