You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Vjeran Marcinko <vj...@email.t-com.hr> on 2017/07/14 07:04:37 UTC

Customizing/overriding date format in StandardQueryParser

Hi all,

If I store my time fields via DateTools, then I can use 
StandardQueryParser's range syntax for specifing date range:

someField:[20170314 TO 20170922]

, but unfortunately this is not date format that I want to present to my 
users. I examined parser API a bit, and the only thing I can find is 
setting Locale which will affect this date format, but unfortunately 
this is still not what satisfies me. The thing I need is somewhere to 
set say some SimpleDateFormat pattern I want, say:
yyyy-MM-HH mm:ss

Now, by guick glance, I can see that QueryParser package and its 
packages is a huge API, and overwhelming for Lucene newbie like me, so 
can someone suggest some way of customizing this format, or even some 
short guidelines how to add to StandardQueryParser some new "function" 
with special syntax which I can ultimately convert underneath to date 
range query which I know how to do programmatically. Say something like 
having beside standard syntax the ability to write for some field:

someField:dateRange(2017-02-03 22:00, 2017-05-00 22:00)

And underneath to construct a Query by using for example 
LongPoint.newRangeQuery("someField", lowerValueMillis, 
upperValueMillis). Of course, this query requires that time fields be 
indexed as LongPoint, but I can do it also, so no problem with that. The 
only thing I need is how to plug in to StandardQueryParser this 
"function specific parser".


Thanx,

Vjeran


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org