tags:

views:

125

answers:

1

Hi Guys,

Is possible in Solr 1.4 to specify which similarity class to use for every search within a single index?

Let's say, I got 2 type of search (keyword and brand). For keyword search, I want to use the DefaultSimilarity class. But, for brand search, I want to use my CustomSimilarity class.

I've been modifying the schema.xml to specify a single similarity class to use. But, I came to this requirement that I have to use 2 different similarity classes.

I'll be glad to here your thoughts on this.

Thanks in advance.

A: 

AFAIK the Similarity can only be defined at the schema/index level and can't be overriden per fieldType or per query. (see this and this).

However you can customize your result ordering using other methods: boosting, function queries, a custom analyzer per field, or even sorting.

The Solr Relevancy Cookbook wiki is a good reference.

Mauricio Scheffer
I've been playing around with function queries (boost) for quite some time now. But, like I said, you cannot directly dictate the ranking using this but you can influence it at some point.
snickernet
@snickernet: if you need to directly set the order, use sorting.
Mauricio Scheffer
@Mauricio, thanks for sharing your thoughts. Yeah, you're right. Maybe I should be better looking on built-in features of Solr/Lucene (i.e. sorting, boosting) rather than building more logic on my own.
snickernet