solribm-watsonretrieve-and-rank

Why can't I have a colon in a Retrieve and Rank Solr query?


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?


Solution

  • 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.