0

If I send a natural-language query to Retrieve and Rank (Solr), it will return an error if the query contains a colon. It seems to be attempting to interpret the word just prior to the colon as a field name.

Is there any way to prevent this, and are there other characters like this to which I should be aware?

dalelane
  • 2,746
  • 1
  • 24
  • 27
David Powell
  • 537
  • 1
  • 4
  • 16

2 Answers2

1

The list of characters you'll need to handle is at http://www.ibm.com/watson/developercloud/doc/retrieve-rank/plugin_query_syntax.shtml - it's at the bottom of the page under the heading "Reserved characters". (This also includes how to handle them)

These include:

Colon (:)
Escape a colon in a query with a backslash.

Double quotation marks (")
Escape double quotation marks in a query with a backslash in field queries.

Backslash (\) Escape character
Escape a backslash in a query with another backslash.

dalelane
  • 2,746
  • 1
  • 24
  • 27
0

You'll have to escape the colon - if your Solr library isn't doing this for you automagically. Escaping uses \ as in most other cases, so foo\:bar should work. Another option might be to wrap the value in quotes (field:"foo:bar").

MatsLindh
  • 49,529
  • 4
  • 53
  • 84