Differences between revisions 4 and 5
Revision 4 as of 2014-08-31 17:31:22
Size: 3423
Comment: pointed readers at the Reference Guide
Revision 5 as of 2016-12-20 21:12:58
Size: 800
Comment: update to standard warning about page migration to CWIKI; remove old content
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
<!> [[Solr4.8]]

{{{#!wiki red/solid
{X} X-( '''This page is outdated and you should read about the Complex Phrase Query Parser at the Solr Reference Guide instead:''' https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-ComplexPhraseQueryParser. {X} X-(
{{{#!wiki important
This page exists for the Solr Community to share Tips, Tricks, and Advice about the
[[https://cwiki.apache.org/solr/Other+Parsers#OtherParsers-ComplexPhraseQueryParser|ComplexPhraseQueryParser]].
 
Reference material previously located on this page has been migrated to the
[[https://cwiki.apache.org/solr/|Official Solr Reference Guide]].
If you need help, please consult the Reference Guide for the version of Solr you are using
for the specific details about using [[https://cwiki.apache.org/solr/Other+Parsers#OtherParsers-ComplexPhraseQueryParser|this feature]].
 
If you'd like to share information about how you use this feature, please [[FrontPage#How_to_edit_this_Wiki|add it to this page]].
/* cwikimigrated */
Line 8: Line 15:
<<TableOfContents>>
Line 11: Line 16:
The Complex phrase query parser plugin provides support for wildcards, ORs etc inside Phrase Queries.

From [[https://lucene.apache.org/core/api/queryparser/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.html|Complex Phrase Query Parser javadocs]]:

{{{
QueryParser which permits complex phrase query syntax e.g. "(john jon jonathan~) peters*"
}}}
Line 20: Line 18:
After indexing example documents under example/exampledocs via 'java -jar post.jar *.xml' SimplePostTool utility.

The query string

{{{
q=manu:"a* c*"&defType=complexphrase
}}}

or

{{{
q={!complexphrase inOrder=true}manu:"a* c*"
}}}

will return :

http://localhost:8983/solr/collection1/select?q=manu:%22a*%20c*%22&defType=complexphrase&fl=manu

{{{#!highlight xml
<doc>
  <str name="manu">Apple Computer Inc.</str>
</doc>
<doc>
  <str name="manu">ASUS Computer Inc.</str>
</doc>
}}}


'''inOrder''' Parameter can be set in two ways.

1) Its default value is true. If you want to set it to false in a permanent way : register query parser with a different name in solrconfig.xml
{{{#!highlight xml
 <!-- Un-ordered complex phrase query parser -->
 <queryParser name="unorderedcomplexphrase" class="org.apache.solr.search.ComplexPhraseQParserPlugin">
   <bool name="inOrder">false</bool>
 </queryParser>
}}}

2) At query time via LocalParams.
{{{
q={!complexphrase inOrder=false df=name}"bla* pla*"
}}}

To mix ordered and unordered clauses in the same query.
{{{
+_query_:"{!complexphrase inOrder=true}manu:\"a* c*\"" +_query_:"{!complexphrase inOrder=false df=name}\"bla* pla*\""
}}}

This was added to Solr through [[https://issues.apache.org/jira/browse/SOLR-1604|SOLR-1604]]
Line 71: Line 19:

=== maxBooleanClauses ===

You may need to increase
{{{
<maxBooleanClauses>1024</maxBooleanClauses>
}}}
according to index size in solrconfig.xml because
{{{
"a* c*"
}}}
is expanded into [[http://lucene.apache.org/core/api/core/org/apache/lucene/search/spans/SpanNearQuery.html|SpanNearQuery]]
{{{
spanNear([spanOr([manu:a, manu:america, manu:apache, manu:apple, manu:asus, manu:ati]), spanOr([manu:canon, manu:co, manu:computer, manu:corp, manu:corsair])], 0, false)
}}}

=== Stopwords ===

Lets say we add '''the''', '''up''', '''to''' to collection1/conf/stopwords.txt file and re-index example docs.
While
{{{
q=features:"Stores up to 15,000"
}}}
returns ''"Stores up to 15,000 songs, 25,000 photos, or 150 hours of video"'',
{{{
q=features:"sto* up to 15*"&defType=complexphrase
}}}
does not return that document because [[http://lucene.apache.org/core/api/core/org/apache/lucene/search/spans/SpanNearQuery.html|SpanNearQuery]] has no good way to handle stopwords in a way analogous to [[http://lucene.apache.org/core/api/core/org/apache/lucene/search/PhraseQuery.html|PhraseQuery]]. It is recommended not to use stopword elimination with this query parser.
If you really really have to remove stopwords, as a workaround, use a custom filter factory that reduces given stopwords to some impossible token.

This page exists for the Solr Community to share Tips, Tricks, and Advice about the ComplexPhraseQueryParser.

Reference material previously located on this page has been migrated to the Official Solr Reference Guide. If you need help, please consult the Reference Guide for the version of Solr you are using for the specific details about using this feature.

If you'd like to share information about how you use this feature, please add it to this page.

Overview

Limitations

ComplexPhraseQueryParser (last edited 2016-12-20 21:12:58 by CassandraTargett)