apache / apache/lucene

QueryParser should have a setDateFormat(DateFormat) method [LUCENE-1361]

Open
#2,438 4 comments 0 reactions 0 assignees View on GitHub
affects-version:2.3.2 legacy-jira-fix-version:4.9 legacy-jira-fix-version:6.0 legacy-jira-priority:Minor module:core/queryparser type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Currently the only way to change the date format used by QueryParser.java is to override the getRangeQuery method. This seems a bit excessive to me. Since QueryParser isn't threadsafe (like DateFormat) I would suggest that a DateFormat field be introduced (protected DateFormat dateFormat) and a setter be introduced (public void setDateFormat(DateFormat format)) so that it's easier to customize the date format in queries. If there are good reasons against this (can't imagine, but who knows) why not introduce a protected 'DateFormat:createDateFormat())' method so that, again, it's easier for clients to override this logic.

---
Migrated from [LUCENE-1361](https://issues.apache.org/jira/browse/LUCENE-1361) by ocean, updated May 09 2016

Contributor guide

Open the contributing guide

Research direction

Start with QueryParser.java and its getRangeQuery method to understand how date formats are currently selected and used. The work is done when callers can customize the query date format through the requested API without overriding getRangeQuery, with the existing behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.