> 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?



Reply via email to