Not enough efficient number search

I am trying to search to number fields in elastic.
When I am searching for 39693 and type 39693 I get the right result.
But when I am typing 963 I don't get any result.

var response = client1.Search(n => n.Index(index)
.Type(type)
.Query(q => q.ConstantScore(f => f.Filter(t => t.Term(documentField, searchWord))))
.Size(searchSize)
.From(0)

                    .Sort(s => s.Descending(SortSpecialField.Score))
                    .TrackScores(true));

The doc says :

The term query finds documents that contain the exact term specified in the inverted index. For instance:

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html#query-dsl-term-query

1 Like

How can I set it finding numbers with one more or one less digit?

It looks like you want to treat your number as a string and search for partial matches. If this is the case you may be able to use ngrams.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.