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

Fix native :fields behavior mismatch with rest #193

Merged

Conversation

dspiteself
Copy link
Contributor

When processing results from a search query 'convert-fields-result' called getValue instead of getValues. This caused the first of the values to be returned. This behavior is inconsistent with the behavior of the rest api which always returns a vector.

When processing results from a search query 'convert-fields-result' called getValue instead of getValues. This caused the first of the values to be returned. This behavior is inconsistent with the behavior of the rest api which always returns a vector.
@dspiteself
Copy link
Contributor Author

Even though tests pass. It is extremely likely this breaks code in the wild.

@favila
Copy link

favila commented Jan 11, 2016

What follows is a higher-level restatement of the problem this patch addresses.

Currently, if you query elasticsearch specifying "fields", e.g.

{"fields": ["fieldA", "fieldB"],
 "query": ...}

With the elastich (and elasticsearch) REST client the result for fields will always be arrays:

// "fields" result from REST
{"hits":
  {"hits": [
    {"fields": {
      "fieldA":["valueA1", "valueA2"],
      "fieldB":["valueB1"]
    }}
  ]}
}

If you issue the same query using the native client, the result for fields will always be scalar and only supply the first value:

// fields result from native client (WRONG)
{"hits":
  {"hits": [
    {"fields": {
      "fieldA":"valueA1", // "valueA2" missing!
      "fieldB":"valueB1"
    }}
  ]}
}

The attached patch makes the second (wrong, native client) result look like the first (correct, REST) result.

@michaelklishin
Copy link
Member

I understand and the right thing to do here is to fix things. Would you mind submitting the same change against 2.1.x-stable? I can cut a point release shortly after. Thank you.

@michaelklishin
Copy link
Member

Actually, don't worry, the change is a single commit so I can trivially cherry pick it :)

michaelklishin added a commit that referenced this pull request Jan 11, 2016
Fix native :fields behavior mismatch with rest
@michaelklishin michaelklishin merged commit 4126a3e into clojurewerkz:master Jan 11, 2016
@michaelklishin
Copy link
Member

2.2.1 is up on Clojars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants