Ah wait, I forgot about dismax 'bq' parameter! That might be a way to
accomplish your first and second use cases. You probably still need the
seperate _text_weight_X fields for your third use case.
Sorry I don't have a complete recipe for you, but hopefully these tools
will help get you somewhere.
http://wiki.apache.org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29
On 8/8/2011 11:16 AM, Jonathan Rochkind wrote:
One kind of hacky way to accomplish some of those tasks involves
creating a lot more Solr fields. (This kind of 'de-normalization' is
often the answer to how to make Solr do something).
So facet fields are ordinarily not tokenized or normalized at all. But
that doesn't work very well for matching query terms. So if you want
actual queries to match on these categories, you probably want an
additional field that is tokenized/analyzed. If you want to boost
different category assignments differently, you probably want
_multiple_ additional tokenized/analyzed fields.
So for instance, create separate analyzed fields for each category
'weight', perhaps using the default 'text' analysis type.
categor_text_weight_1
category_text_weight_2
etc
Then use dismax to query, include all those category_text_* fields in
the 'qf', and boost the higher weight ones more than the lower weight
ones.
That will handle a number of your use cases, but not all of them.
Your first two cases are the most problematic:
"filter: category=some_category_name, query: *.* - Results should be
score by the above mentioned weight "
So Solr doesn't really work like that. Normally a filter does not
effect the scoring of the actual results _at all_. But if you change
the query to:
&fq=category:some_category
&q=some_category
&defType=dismax
&qf=category_text_weight1, category_text_weight2^10,
category_text_weight3^20
THEN, with the multiple analyzed category_text_weight_* fields, as
described above, I think it should do what you want. You may have to
play with exactly what boost to give to each field.
But your second use case is still tricky.
Solr doesn't really do exactly what you ask, but by using this method
I think you can figure out hacky ways to accomplish it. I'm not sure
if it will solve all of your use cases, but maybe this will give you a
start to figuring it out.
On 8/5/2011 6:55 AM, Michael Lorz wrote:
Hi all,
I have documents which are (manually) tagged whith categories. Each
category-document relation has a weight between 1 and 5:
5: document fits perfectly in this category,
.
.
1: document may be considered as belonging to this category.
I would now like to use this information with solr. At the moment, I
don't use
the weight at all:
<field name="category" type="string" indexed="true" stored="true"
multiValued="true"/>
Both the category as well as the document body are specified as query
fields
(<str name="qf"> in solrconfig.xml).
What I would like is the following:
- filter: category=some_category_name, query: *.* - Results should
be score by
the above mentioned weight
- filter: category=some_category_name, query: some_keyword - Results
should be
scored by a combination of the score of 'some_keyword' and the above
mentioned
weight
- filter: none, query: some_category_name - Documents with category
'some_category_name' should be found as well as documents which
contain the term
'some_category_name'. Results should be scored by a combination of
the score of
'some_keyword' and the above mentioned weight
Do you have any ideas how this could be done?
Thanks in advance
Michi