Hi Radu,
thank you for taking the time to assist me with this problem.
Since the search time is highly important, my first choice would have been
to use the second option that you mentioned, and
use a separate index for each product such as TV.
unfortunately, there is another restriction, that makes the problem even
more complex.
I need to be able to set a date range for the query.
For example, if again I am looking for the user count of TOSHIBA buyers at
18 - 20 of May, I should get count=1 (as before).But if my range is 18 -21
of May (as appear below), I should get count = 0, because at that range,
there is no user that his last TV was TOSHIBA.
So as you can see, creating an user_tv_index that gets overridden on each
TV bought is a problem, because I will still need the info for old actions.
Do you think that there is still a good way of retrieving this information
without slowing the search time?
Thanks in advanced. I highly appreciate your help.
Oren
user1|2013-05-18|TV,SAMSUNG
user1|2013-05-19|TV,TOSHIBA
user1|2013-05-20|PC
user2|2013-05-18|TV,TOSHIBA
user2|2013-05-19|TV,SAMSUNG
user2|2013-05-20|PC
user1|2013-05-21|TV,SAMSUNG
On Fri, Jun 28, 2013 at 3:41 PM, Radu Gheorghe-2 [via Elasticsearch Users] <
ml-node+s115913n4037241h6@n3.nabble.com> wrote:
Hello,
I don't see a clean way of doing this. But you can pay some prices, either
at query or at index time, to obtain this.
For example, at query time, you can try to get a list of unique users by
doing a terms facethttp://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet/on the user field. Then, you can do a multi
search http://www.elasticsearch.org/guide/reference/api/multi-search/for all the users to see what was the last thing they bought. Finally, you
can count on the application side which of those was a Toshiba TV. Very
slow and doesn't scale, but you can do anything.
On the other hand, if you have a predefined list of such queries, you can
a separate index (eg: last_item_bought) for each query. For example, with
this one, you can have an index where, each time a use buys something, you
update the document with their name as the ID, and the item they bought. It
shouldn't hurt indexing performance too much. When you want to search, you
just do a filter on "tv" and "toshiba", with size=0 and see the number of
hits.
Best regards,
Radu
On Thu, Jun 27, 2013 at 6:21 PM, oreno <[hidden email]http://user/SendEmail.jtp?type=node&node=4037241&i=0
wrote:
Hi All,
I have a problem that I hope someone can help me with:
I have the next mapping for my user index -> docs(users) containing events
in which the user bought different products. each event(date) can contain
several products. I would like to retrieve the count of users that their
last purchase of TV was TOSHIBA. for that I am willing to have a 'TV' as a
product by itself.
So in case a have the next events:
user1|2013-05-18|TV,SAMSUNG
user1|2013-05-19|TV,TOSHIBA
user1|2013-05-20|PC
user2|2013-05-18|TV,TOSHIBA
user2|2013-05-19|TV,SAMSUNG
user2|2013-05-20|PC
user1 should be counted because its last bought TV was TOSHIBA but user2
should not.
Does anyone have an idea how to approach this query?
I tried several times but I'm new to elasticsearch so no success yet.
Thanks in advanced,
{
"user" : {
"properties" : {
"name": {"type" : "string"},
"events" : {
"type" : "nested",
"properties" : {
"event_time" : {"type" : "Date"},
"products" : { "properties" : { "product" : {"type" : "string"} }
}
}
}
}
}
}
--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/elasticsearch-count-users-query-tp4037172.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.
--
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 [hidden email]http://user/SendEmail.jtp?type=node&node=4037241&i=1
.
For more options, visit https://groups.google.com/groups/opt_out.
--
http://sematext.com/ -- Elasticsearch -- Solr -- Lucene
--
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 [hidden email]http://user/SendEmail.jtp?type=node&node=4037241&i=2
.
For more options, visit https://groups.google.com/groups/opt_out.
If you reply to this email, your message will be added to the discussion
below:
http://elasticsearch-users.115913.n3.nabble.com/elasticsearch-count-users-query-tp4037172p4037241.html
To unsubscribe from elasticsearch - count users query, click herehttp://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4037172&code=b3Jlbm9AZXhlbGF0ZS5jb218NDAzNzE3Mnw4ODk1Mjk2Nzg=
.
NAMLhttp://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers!nabble%3Aemail.naml-instant_emails!nabble%3Aemail.naml-send_instant_email!nabble%3Aemail.naml
--
Oren Orgad
eXelate
software engineer
p: +972- 72-2221329 | m: +972- 52-3401051 | e: oreno@exelate.com