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
Error Installing Debugger: Failed to Build Gem Native Extension with Ruby-1.9.3-P362
Preserve Newline in Text Area with Ruby on Rails
Ruby: Conditional Matrix? Case with Multiple Conditions
Cannot Use Ruby-Debug19 with 1.9.3-P0
Problem Signing Out with Devise on My App
Ruby Dsl (Domain Specific Language) Repositories, Examples
How to Wrap the Invocation of a Ruby Method by Including a Module
Kernel#Gets Attempts to Read File Instead of Standard Input
How to Set the Actionmailer Default_Url_Options's :Host Dynamically to the Request's Hostname
How to Change "Devise: Password Reset Instruction Email's Subject"
Convert Non-Breaking Spaces to Spaces in Ruby