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

Migrate deprecated match query syntax #11554

Merged
merged 6 commits into from May 5, 2017
Jump to file or symbol
Failed to load files and symbols.
+4 −2
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Give condition a name

  • Loading branch information...
Bargs committed May 4, 2017
commit ff2158ad04ae6c4ae73e07d04a826320e5d15f38
@@ -3,9 +3,8 @@ import _ from 'lodash';
export function migrateFilter(filter) {

This comment has been minimized.

@lukasolson

lukasolson May 2, 2017

Member

Could you add a unit test for this?

This comment has been minimized.

@Bargs

Bargs May 4, 2017

Contributor

👍 f2798b5

if (filter.match) {
const fieldName = Object.keys(filter.match)[0];
const params = filter.match[fieldName];
if (_.isPlainObject(params) && params.type === 'phrase') {
if (isMatchPhraseFilter(filter, fieldName)) {
const newFilter = {
match_phrase: _.clone(filter.match, true)

This comment has been minimized.

@weltenwort

weltenwort May 3, 2017

Contributor

How about turning this into a single declarative expression like

return {
  match_phrase: {
    [fieldName]: _.omit(params, 'type'),
  },
};

This comment has been minimized.

@Bargs

Bargs May 4, 2017

Contributor

👍 9c75310

};
@@ -17,3 +16,6 @@ export function migrateFilter(filter) {
return filter;
}
function isMatchPhraseFilter(filter, fieldName) {
return _.get(filter, ['match', fieldName, 'type']) === 'phrase';
}
ProTip! Use n and p to navigate between commits in a pull request.