Solr Sanitizing Query

solr sanitizing query

I don't know any code that does this, but theoretically it could be done by looking at the parsing code in Lucene and searching for throw new ParseException (only 16 matches!).

In practice, I think you're better off just catching any solr exceptions in your code and showing an "invalid query" message or something like that.

EDIT: Here are a couple of "sanitizers":

  • http://pivotallabs.com/users/zach/blog/articles/937-sanitizing-solr-requests
  • http://github.com/jvoorhis/lucene_query
  • http://e-mats.org/2010/01/escaping-characters-in-a-solr-query-solr-url/

Any way to compose Solr queries as POSTs in XML,JSON?

Yes, you can just switch from GET to POST and it just works.

I wouldn't do it by default however:

  • You lose web server logging
  • GET is more appropriate than POST for queries because of its safe semantics
  • You lose HTTP caching

How to search with date using apache solr

from schema it appears that you have not indexed date fields from your tables, once you index date fields like created and modified columns, you can make queries like these:

(created:[NOW-1MONTH TO NOW]) //for current month

(created:[NOW-3MONTH TO NOW-1MONTH]) //created within last three months but not in current month

and so on, do some experiment with other units of time and (+/-) operators, you will get desired queries.



Related Topics



Leave a reply



Submit