I have an index field called: texts
The field contains values like: 12/1
And also: 1/12
The problem is when I query: texts:"1/*"
It's finding also 12/1
it's like the slash don't have any meaning.
How I can limit the results by order?
(I've tried texts:"1\/*"
and it's not working)
The type of the field:
<fieldType class="org.apache.solr.schema.TextField" name="TextField">
The problem is that you're using the TextField
type that performs tokenization of your text, and then additional filtering, like, lower-casing, etc. In your case, you don't have value 12/1
in your index, but you have 2 values, 12
and 1
, for both first & second values, so you search for 1/*
will match to both records because search will be performed for value 1
that was generated after tokenization of your input.
To keep string from tokenization you need:
StrField
type instead - but in this case, the string will be indexed as-is, without lower-casing, etc.solr.KeywordTokenizerFactory
as tokenizer, and add corresponding filters.You can read more in the DataStax documentation. Also note, that starting with version 6, default type for text
data is StrField
, and you need explicitly define TextField
if you need tokenization, etc.