I need to sort SOLR search results based on position of search query.For example I have 4 documents
1.demo of solr lucene
2.lucene focuses mainly on text indexing
3.explain lucene with example
4.lucene is an open source
when I will search with query text lucene then I need result in following order
2.lucene focuses mainly on text indexing
4.lucene is an open source
3.explain lucene with example
1.demo of solr lucene
i.e. boost search query in first and second position higher than other
Following is field defination I have used on which I need position based sort
*<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.WordDelimiterGraphFilterFactory" catenateNumbers="1" generateNumberParts="1" protected="protwords.txt" splitOnCaseChange="1" generateWordParts="0" preserveOriginal="1" catenateAll="0" catenateWords="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" expand="true" ignoreCase="true" synonyms="synonyms.txt"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.WordDelimiterGraphFilterFactory" catenateNumbers="1" generateNumberParts="1" protected="protwords.txt" splitOnCaseChange="1" generateWordParts="0" preserveOriginal="1" catenateAll="0" catenateWords="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<similarity class="CustomSimilarity" />
</fieldType>*
for this I have tried to disable termfrequency by adding customSimilarity class in solr but I am getting error as
Plugin init failure for [schema.xml] fieldType : Error loading class
Following is the class defination for CustomSimilarity classs
import org.apache.lucene.analysis.payloads.PayloadHelper;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.schema.SimilarityFactory;
import org.apache.solr.search.similarities.SchemaSimilarityFactory;
public class CustomSimilarity extends SchemaSimilarityFactory{
public float tf(float freq) {
return 1.0f;
}
}
And jar file path in solrconfig
<lib dir="${solr.install.dir:../../../..}/dist/" regex=".*.jar" />
Any help will be appriciated