0
votes

I have imported data from my database into Solr for querying purpose.

A sample of data is as below...

NAMATJIRA,DRIVE,,WARAMANGA,ACT
DOUGLAS WATERHOUSE,DRIVE,,DUNLOP,ACT
WARDELL,DRIVE,,BARDEN RIDGE,NSW

In solr admin page, when I run the query

street_name:wa* AND street_name:drive*

I get all the records as above. Is there a way to filter so that I get only the ones starting with WA?

UPDATE : Added schema information

<field name="street_name" type="text_general" indexed="true" stored="true"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
         <tokenizer class="solr.KeywordTokenizerFactory"/>    
       <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>
1
show us your solr schemaAshraful Islam

1 Answers

1
votes

the type you are using it to analyze that field is tokenizing that into several terms, so

NAMATJIRA,DRIVE,,WARAMANGA,ACT

becomes (a field containing multiple terms, then it's probably also lowercasing etc)

NAMATJIRA 
DRIVE
WARAMANGA
ACT

That is why your query matches it, because one of the values starts with 'wa'.

To fix this, just change the type of your field to use KeywordTokenizerFactory, that keeps everything as a single term.