question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Int search/filter resulting in no results.

See original GitHub issue

Hello, 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:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
yohsiicommented, Mar 28, 2022

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

3reactions
diegolaz79commented, Mar 28, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found