Am 26.04.2012 00:57, schrieb Joe:
Hi,

I'm using the solrj API to query my SOLR 3.6 index. I have multiple text
fields, which I would like to weight differently. From what I've read, I
should be able to do this using the dismax or edismax query types. I've
tried the following:

SolrQuery query = new SolrQuery();
query.setQuery( "title:apples oranges content:apples oranges");
query.setQueryType("edismax");
query.set("qf", "title^10.0 content^1.0");
QueryResponse rsp = m_Server.query( query );

Why do you try to construct your own query, when you're using an edismax query with a defined qf parameter?

What you're searching is the text "title:apples oranges content:apples oranges". Depending on your analyzer chain, it might be that title:appes and content:apples are kept as one token, so nothing is found because there's no such token in the index.

Why don't you simply query for "apples oranges"? That's how (e)dismax is made for. Have a deeper look at http://wiki.apache.org/solr/DisMax.

BTW, if you used the above query in a Lucene parser, it would look for "apples" in title and content field, but look for "oranges" in your default search field. This is because you didn't quote "apples oranges". Since you want to use Edismax, you can ignore this, it's just that you current query won't work as expected in both cases.

-Kuli

Reply via email to