0

I would like to fire complex queries in Solr 4. If I am using Lucene, I can search using XML Query parser and get the results I need. However, I am not able to see how to use the XML Query Parser in Solr.

I need to be able to execute queries with proximity searches, booleans, wildcards, span or, phrases (although these can be handled by proximity searches).

Guidance on material on how to proceed also welcome.

Regards Puneet

Puneet
  • 472
  • 3
  • 14

3 Answers3

2

As far as I know it's still a work in progress. More info can be found at their Jira. You can of course use the normal query language, it's also capable of doing pretty complex things, for example:

"a proximity search"~2 AND *wildcards* OR "a phrase"

As you can see you can search for phrases, boolean operators (AND, OR, ...), span, proximity and wildcards. For more information about the query syntax look at the Lucene documentation. Solr also added some extra features on top of the Lucene query parser and more information about that can be found at the Solr wiki.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
  • I need to be able to do things like proximity search between 2 phrases, expansion of wildcards in phrases etc. I don't think that is possible with the normal query language. Or even the eDisMax parser. Please correct me if I am wrong. – Puneet May 13 '13 at 09:10
  • I'm not sure if it works, but try the answer provided in this question: http://stackoverflow.com/a/4079305/1915448 – g00glen00b May 13 '13 at 09:20
  • Although this should solve the issue of phrase proximity it still will not cover for expansion of wildcards in phrases etc. I am really looking for something along the lines of the XML Query Parser that is available in Lucene. If a JSON version of the same is available, that too should help. – Puneet May 13 '13 at 10:27
  • You can probably still achieve it with extremely complex query strings (not that I recommend doing it). You will probably have to wait until someone creates such a query parser or implement one yourself. AFAIK, there is only the Lucene, eDismax and Dismax query parser. – g00glen00b May 13 '13 at 10:46
  • I guessed as much. Pointer to how to go about implementing a query parser for solr would be helpful. Thanks. – Puneet May 13 '13 at 12:03
  • Never did it myself but this is all I can find at the wiki: http://wiki.apache.org/solr/SolrPlugins#QParserPlugin – g00glen00b May 14 '13 at 21:02
2

Solr 4.8 now has the "complexphrase" query parser built in that can construct all sorts of complex proximity queries (i.e. phrase queries with embedded boolean logic and wildcards).

Flexo
  • 87,323
  • 22
  • 191
  • 272
Yonik
  • 2,341
  • 1
  • 18
  • 14
  • Yonik,does this allow for phrase near phrase kind of searches i.e. proximity searches for phrases? – Puneet May 31 '14 at 05:12
2

you can use the query url as http://xx.xxx.xx.xx:8983/solr/collectionname/select?indent=on&q= {!complexphrase%20inOrder=true}"good*"&wt=json&fl=Category,keywords,ImageID

Nanda Kumar
  • 2,016
  • 1
  • 9
  • 12