Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "locale" parameter to query_string and simple_query_string #5131

Closed
wants to merge 1 commit into from

Conversation

dakrone
Copy link
Member

@dakrone dakrone commented Feb 14, 2014

Both default to Locale.ROOT

Fixes #5128

@@ -186,6 +188,13 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
qpSettings.quoteFieldSuffix(parser.textOrNull());
} else if ("lenient".equalsIgnoreCase(currentFieldName)) {
qpSettings.lenient(parser.booleanValue());
} else if ("locale".equals(currentFieldName)) {
String localeStr = parser.text();
Locale locale = Locale.forLanguageTag(localeStr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this API is java 1.7 only that is why I added public static Locale parseLocale(String locale) to DateFieldMapper - I think we should add a utils class somewhere to expose this?

@s1monw
Copy link
Contributor

s1monw commented Feb 19, 2014

except of the fact that this uses java 1.7 only APIs this looks awesome!

@@ -71,6 +71,9 @@ both>>.

|`lenient` |If set to `true` will cause format based failures (like
providing text to a numeric field) to be ignored.

|`locale` | Locale that should be used for string conversions. Defaults to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs a coming[1.1.0]

@dakrone
Copy link
Member Author

dakrone commented Feb 20, 2014

@s1monw I removed the 1.7-specific APIs from this

@s1monw
Copy link
Contributor

s1monw commented Feb 20, 2014

I think this looks great - Can we maybe have a LocaleUtils that has a Locale parse(String) and a String toString(Locale) method with some // JAVA7 - use toLanguageTag in it? I think we can hide this behind a utils class and once we move to Java7 which is hopefully not far out we can use the new API across the board?

@dakrone
Copy link
Member Author

dakrone commented Feb 20, 2014

Sounds good, I'll do that. Hopefully going java 7 minimum is not too far out :)

@s1monw
Copy link
Contributor

s1monw commented Feb 20, 2014

LGTM +1 to squash and push

Fixes elastic#5128

Remove java 7 specific Locale functions, add "coming[1.1.0]" to documentation

add LocaleUtils utility class for dealing with Locale functions
@dakrone
Copy link
Member Author

dakrone commented Feb 20, 2014

Merged in 8f8cc72

@dakrone dakrone closed this Feb 20, 2014
@dakrone dakrone deleted the 5128-query-string-locale branch April 21, 2014 22:59
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v1.1.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query_string and simple_query_string should allow selective a Locale
3 participants