On Wed, Jun 17, 2015 at 2:44 PM, Sreekant Sreedharan <sreeka...@alamy.com> wrote:
> I have a requirement to make SOLR a turnkey replacement for our legacy > search > engine. To do this, the queries supported by the legacy search engine has > to > be supported by SOLR. > > To do this, I have implemented a QueryParser. I've implemented it several > ways: > > 1. I've copied the implementation in LuceneQParser, that uses the > SolrQueryParser, and essentially replaces the params of my QParser > replacing > it with the an instance of the ModifiableSolrParams object. Taking care to > copy what exists in the previous params object and replacing the 'fq' > argument that is mapped from the query argument supported by the legacy > search engine. The problem with this approach is that ModifiableSolrParams > does not allow you to have multiple fq arguments in it. http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/common/params/ModifiableSolrParams.html#add%28java.lang.String,%20java.lang.String...%29 > But in some cases, > we need to support multiple field restrictions. I would have preferred this > solution because I imagine that leveraging SOLR's robust query parsing > mechanism is more easier than building a Lucene Query from scratch. > > 2. The second approach, uses a BooleanQuery and attempts to construct the > entire query from the query parameters. This approach seemed more > promising, > and works for most field restrictions. But I hit a road block. The filter > seems to work for all string fields. But when I declare a field as an > integer field in my schema.xml config file, the search does not return the > very same documents. I am not sure why? > Integers are encoded differently rather than we print them, it's done via calling FieldType through Analyzer QueryBuilder.createFieldQuery(Analyzer, Occur, String, String, boolean, int) it's a way longer journey. > I was wondering what the best approach to this problem is (either 1 or 2 > above, or something even better). And I was wondering how to fix the > problem > in each of the above cases. > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/QueryParser-to-translate-query-arguments-tp4212394.html > Sent from the Solr - User mailing list archive at Nabble.com. > -- Sincerely yours Mikhail Khludnev Principal Engineer, Grid Dynamics <http://www.griddynamics.com> <mkhlud...@griddynamics.com>