TERACytE
TERACytE

Reputation: 7853

Solr search is returning partial string matches

Using Solr 3.6.1, I have this field in my schema.xml:

<field name="names" type="text_general" indexed="true" stored="false" multiValued="true"/>
<dynamicField name="names_*" type="text_general" indexed="true" stored="true"/>

The documentation in the schema.xml states that "text_general" should:

I have two documents indexed in Solr with this data for the field:

<!-- doc 1 -->
<str name="names_data">Name ABC Dev Loc</str> 

<!-- doc 2 -->
<str name="names_data">Name ABC Dev Location</str>

When I execute the following query:

id:(doc1 OR doc2) AND names:Dev+Location)

Both documents are returned. I would have expected that only doc2 would have been returned based on my understanding of how Solr's StandardTokenizer works.

Why does "Dev+Location" match "Dev Loc" and "Dev Location"?

Upvotes: 1

Views: 674

Answers (2)

d whelan
d whelan

Reputation: 804

This might be why.

This part of the query names:Dev+Location is only searching where names:Dev since the Location term does not have a field name qualifier it is searching for Location against whatever the <defaultSearchField> is set to in schema.xml

So you could try to quote the field like names:"Dev Location" or prefix it names:Dev AND names:Location

Upvotes: 0

Bohemian
Bohemian

Reputation: 424973

The type text_general is probably configured to use a stemmer, which is treating Loc as a variant of Location.

You could configure the type to not use a stemmer, or try searching for the whole string using names:"Dev Location"

Upvotes: 2

Related Questions