简体   繁体   中英

Apache SOLR and string range search

Is possible to search by range on field type 'string'?

fieldString:[A TO B]

or

fieldString:[U-00* TO U-009]

mean that give result with fields where all characters sequences are between A to B or all U-000 between U-009

Now I got some few field with values from U-001, U-002... to U-009

I try: fieldString:[U-00* TO U-009] but this dont work
fieldString:/U-00[0-9]/ and also the same non results

Yes, it is possible. But the results may depend on how you analyzed the string in the index. If the string is just A or B, there is no problem; but on some tokenizing you may get all results containing A or B.

schema.xml:
<types>
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" />
    ...
</types>

<fields>
    ...
    <field name="isbn" type="string" indexed="true" stored="true" multiValued="false" />
    ...
</fields>

solrconfig.xml:
<requestHandler class="solr.SearchHandler" name="standard">
</requestHandler>

As you see, there is nothing special. String type is not treated by any filters, but just stored as is. And I use the standard query parser. In this configuration your example works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM