There are two text fields in solr, both of them are white space tokenized and have lower case filter. below is the schema:
<fieldType name="text_ac" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="field1" type="text_ac" indexed="true" stored="true" required="false" omitNorms="true" default=""/>
<field name="field2" type="text_ac" indexed="true" stored="true" required="false" omitNorms="true" default=""/>
How to query solr to return results that the whole string of field1 is same as field2 at query time (field1==field2)?
Thanks.
Have you tried the function 'strdist' and range query 'frange'? A range query like this would help:
{!frange l=1 u=1}strdist(field1, field2, edit)
Comparing one field to another within a document is not supported in either Solr or Lucene core, to my knowledge.
A simple way to accomplish this would be to perform the comparison at index time, and store the result in the index. That is, if you have
field1
andfield2
, create a field1_equals_2
, and index it withtrue
, if they are equal based on your comparison when adding the document. Then you can simply search for1_equals_2:true
.