Hello

I am currently trying to migrate an sql application to Elasticsearch. 

I need to be able to select a collection of results from an index 
which, for given search conditions, have distinct pairings of two certain 
columns. In sql I do the following two queries:

Query 1: 
SELECT column_A, column_B, GROUP_CONCAT (table_name..id) id FROM 
`table_name` WHERE `column_?` = '<something>' GROUP BY column_A, 
column_B,column_
?

Query 2:
 SELECT `table_name`.* FROM `table_name `  WHERE  `column_?` = '<something>' 
AND 
(`table_name.id` IN (<ids_from_previous_query>))

The first query returns me a list of ids from table_name such that each id 
satisfies the condition `column_?` = '<something>' and the record with that 
id has a distinct [column_A,column_B]

The second query then returns me all the records satisfying  `column_?` = 
'<something>' but only from that range of ids (I realise I probably do not 
need to do `column_?` = '<something> again in the second query.)

The result is that each record returned by the second query has satisfies 
the condition  `column_?` = '<something>'  and I am only returned one 
record for each [column_A,column_B] paring.

Since there is not really a 'distinct' option yet I am having trouble 
finding a way replicate this output with ES and wondered if anyone might 
have any thoughts as how I might go about it?

At the moment I am open to any mapping / query combinations that will 
achieve what I need.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/6a857778-0399-4b3c-9973-a3e353436311%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to