Hello, Thanks. This would absolutely serve. I thought of doing it in queryparser part which I mentioned in first mail. But if the query is a complex one, then it would become a bit complicated. Thats why I wanted to know whether there is any other way which is similar to the second point in my first mail..
---> " 2) I could first pass the incoming query string to a default parser provided by Solr and then retrieve all the Terms ( and then add synonym terms ) using by calling Query.extractTerms() ..on the returned Query object but I am unable to get how to point out relations among the Terms like.. whether its Term1 OR Term2 AND Term3, or Term1 AND Term2 AND Term3 .. or something else. " Thanks. 2009/12/23 AHMET ARSLAN <iori...@yahoo.com>: >> Hi, >> I have explored >> "DisMaxRequestHandler". It could serve for some >> of my purposes but not all. >> 1) It seems we have to decide that alternative field list >> beforehand >> and declare them in the config.xml . But the field list for >> which >> synonyms are to be considered is not definite ( at least in >> the view >> of declaring manually in the xml ), its getting updated >> frequently >> depending upon the indexed fiels. Anyways if the list is >> too big its >> hard to follow this approach. >> >> 2) I have another issue too.. We could mention city , >> place, town in >> the dismax declaration, but what if there is another list >> of synonyms >> like .. if the query is "organisation : xyz".. for which I >> would like >> to convert the query to >> organisation:xyz OR company:xyz OR >> institution:xyz . >> >> As far as I explored it is not possible >> to link city, organisation >> to their corresponding synonyms seperately, but we can only >> decalre a >> set of default field names to be searched. >> If I am wrong at any point, please >> let me know. >> Any other suggestions? >> Thanks. > > If you want field synonyms seperately, then you can extend > org.apache.solr.handler.component.SearchHandler and override > > public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) > { > > final String q = req.getParams().get(CommonParams.Q); > > String expandedQuery = "process incoming query with string operations e.g. > if q.startsWith(organisation:) "; > > ModifiableSolrParams solrParams = new > ModifiableSolrParams(req.getParams()); > > solrParams.set(CommonParams.Q, expandedQuery); > req.setParams(solrParams); > > super.handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp); > } > > Then register this new request handler in solrconfig.xml and use it. > Does this approach serve your purposes? > > > >