PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, December 11, 2022

[FIXED] How to write a solr query for retrieving all records with numeric field value less then specified?

 December 11, 2022     java, lucene, solr, solrj, syntax     No comments   

Issue

Let's assume we have a set of mp3-players with names and prices.

How to write a correct solr query for finding all goods with a certain name and with price less then 100$?

q = "(name:(ipod) AND price ???? 100.0)"


Solution

I don't think the query parser supports < operator. You have to define a RangeQuery explicitly. You can then attach a name query to that using a BooleanQuery.

Update: Apparently, I was wrong. In fact, Solr's query parser is smarter than Lucene's. Here is your answer: https://lucene.apache.org/solr/guide/8_0/the-standard-query-parser.html#differences-between-lucene-s-classic-query-parser-and-solr-s-standard-query-parser

field:[* TO 100] finds all field values less than or equal to 100



Answered By - Eser Aygün
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing