Int search/filter resulting in no results.
See original GitHub issueHello, I’m doing a search first by text and then a second search with same text by adding some number filters: First search, results in a lot of results {+(username:carlos address:carlos country:carlos description:carlos notes:carlos ) }
I then add a filter of userid = 1.
Tried first like a TextField:
Query q = new TermQuery(new Term("userid", userid.Trim().ToLower()));
booleanQuery.Add(q, Occur.MUST);
resulting in
{+(username:*carlos* address:*carlos* country:*carlos* description:*carlos* notes:*carlos* ) +usrid:1}
Then like a number range
int usrID = int.Parse(userid);
Query q = NumericRangeQuery.NewInt32Range("userid", usrID, usrID, true, true);
booleanQuery.Add(q, Occur.MUST);
resuing in
{+(username:*carlos* address:*carlos* country:*carlos* description:*carlos* notes:*carlos* ) +usrid:[1 TO 1]}
While indexing, these are the two approaches I took:
new Int32Field("userid", (int)(userID != null ? userID : 0), Field.Store.YES),
new TextField("userid",(userID != null ? userID.ToString() : ""), Field.Store.YES),
And for analyer, I’m using
IDictionary<string, Analyzer> customAnalyzerPerField = new Dictionary<string, Analyzer>();
customAnalyzerPerField ["userid"] = new StandardAnalyzer(LuceneVersion.LUCENE_48);
// also tried customAnalyzerPerField ["userid"] = new WhitespaceAnalyzer(LuceneVersion.LUCENE_48);
Any ideas on why its filtering to empty? (I checked DB and for that field there are a few rows that should match).
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Search doesn't return results in Django-rest-framework
I am very new to django. I am able to view the result in postman but the api end point doesn't give back...
Read more >GraphQL Search and Filter – How to ...
Searching and filtering is a standard part of any GraphQL API. In this article, we'll learn how to add filtering capabilities to your...
Read more >Filters in Azure Cognitive Search
Numeric fields are retrievable and can appear in search results, but they aren't searchable (subject to full text search) individually. If you ...
Read more >Use search filters with EWS in Exchange
The following example shows you how to use EWS to create a search filter to return all items that have a value in...
Read more >Filtering in C# – How to Filter a List with Code Examples
Filtering refers to the process of restricting the result set to contain only those elements that satisfy a specified condition.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i’ve written a custom query parser for my cms https://github.com/yohsii/puck-core/blob/master/core/PuckLucene/PuckQueryParser.cs
starting line 89 should handle your integer search
worked like a charm