ElasticSearch - how to SUM function_score by field


(Jay Hilden) #1

I have a query that is using function_score to rank the results. Here is a
sample of what is returned:

{
"_index": "clone",
"_type": "authEvent",
"_id": "6431823",
"_score": 4.8,
"fields": {
"authInput.uID": "MPXWDKW2P",
"authResult.productValue": 1,
"authInput.userName": "F936F3AA-E26C-48DB-BDBC-44956B634260",
"authResult.authEventDate": "2014-02-27T09:29:30.703125-06:00",
"authResult.rulesFailed": [
"AuthCountByUser"
]
}
}

What I want to is take the results and run the equivalent of this SQL
statement:

SELECT TOP 20 "authInput.userName", SUM("_score")
FROM foo
GROUP BY "authInput.userName"
ORDER BY SUM("_score") DESC

How can I do this with ES?

NOTE: I'm using ES 0.9x, we will be moving to 1.0.0 soon but we have not
yet.

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/dc11fcb9-8954-4d0a-8996-afd1f73290f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Binh Ly-2) #2

Unfortunately, subqueries are not supported. What you can do is dump the
results of your first query into an index. And then you can do a
terms_stats facet on that dump to get your final results:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-stats-facet.html

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/04770395-4c81-4d42-9566-df763a39fb0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Jay Hilden) #3

Thanks for the response Binh. Is there a way to pipe the response from my
first query directly into a new index without round tripping the data back
to the server that requested the query?

On Mon, Mar 10, 2014 at 1:09 PM, Binh Ly binhly_es@yahoo.com wrote:

Unfortunately, subqueries are not supported. What you can do is dump the
results of your first query into an index. And then you can do a
terms_stats facet on that dump to get your final results:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-stats-facet.html

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/hiTA1hsdLr8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/04770395-4c81-4d42-9566-df763a39fb0c%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/04770395-4c81-4d42-9566-df763a39fb0c%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAD3qxy56ohK9icugkoo2vebJkyXLNZfBpQterFO2ib7zU1aXFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4