Search code examples
pythonsolrpysolr

Solr search with escaping solr reserved keywords


How do i query fields that contain solr reserved keywords as ":" in solr?

For instance,

q = 'uri:http://www.example.com'

throws up an error for "http://www.example.com" containing reserved word ":"


Solution

  • I just tested this and it seem that simply escaping ":" like ":" does the trick:

    q = 'uri:http\://www.example.com'
    

    For my the index of my own site I tend to simply store the path of the URL though as I know the domain myself so that wasn't an issue for me before. But if you index external URLs then of course you need the full URL.