Group By Field Value


(poncho) #1

Hi All,

I'm moving from MySQL to ElasticSearch. I'm loving ElasticSearch's speed and ease of setup, well done!

Using ElasticSearch, I'm creating a database of websites that have the following fields:
document_id (i.e. abc123)
domain (i.e. elasticsearch.org )
url (i.e. http://www.elasticsearch.org/ )
document_title (i.e. elasticsearch - - Open Source, Distributed, RESTful, Search Engine)
document_text (i.e. You know, for Search. So, we build a web site or an app....)

When searching, I would like to display the results (sorted by score) and group the results by domain. So i'm trying to be fair and show 10 different domains in the result rather than showing 10 results from the same domain. If you search on Google you'll know what I mean.

In SQL I could achieve this using the following query:
SELECT * FROM table WHERE document_title LIKE '%elasticsearch%' GROUP BY domain

How could I get a similar GROUP BY results with elasticsearch.

Cheers Poncho


(Karussell) #2

That is not possible today:

but you can do it on the client side (fetch up some more docs and
collapse by yourself)

Another way would be to index domains not documents ... but that is
probably not what you want.

Regards,
Peter.

On Apr 25, 8:45 am, poncho nat...@noisefm.com.au wrote:

Hi All,

I'm moving from MySQL to ElasticSearch. I'm loving ElasticSearch's speed and
ease of setup, well done!

Using ElasticSearch, I'm creating a database of websites that have the
following fields:
document_id (i.e. abc123)
domain (i.e. elasticsearch.org )
url (i.e.http://www.elasticsearch.org/)
document_title (i.e. elasticsearch - - Open Source, Distributed, RESTful,
Search Engine)
document_text (i.e. You know, for Search. So, we build a web site or an
app....)

When searching, I would like to display the results (sorted by score) and
group the results by domain. So i'm trying to be fair and show 10 different
domains in the result rather than showing 10 results from the same domain.
If you search on Google you'll know what I mean.

In SQL I could achieve this using the following query:
SELECT * FROM table WHERE document_title LIKE '%elasticsearch%' GROUP BY
domain

How could I get a similar GROUP BY results with elasticsearch.

Cheers Poncho

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Group-By-Field-Value-...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(poncho) #3

Thanks Peter, I am looking into storing domains so this might be a solution.

Alternatively, after reading up on the parent-child feature of ES, could this be something I could use.

The way I look at this is I have a domain (i.e. blahblah.com), then under this blahblah.com domain I could have many documents (i.e. blahblah.com/somepage.html, blahblah.com/index.html, blahblah.com/someotherpage.php).

Would making these document children work?

Therefore, could I search on children documents to return the parent document?

Thanks again!


(Karussell) #4

Sorry, I'm not familiar with the child parent things and API. Maybe
you could ask on freenode?

On Apr 30, 4:15 pm, poncho nat...@noisefm.com.au wrote:

Thanks Peter, I am looking into storing domains so this might be a solution.

Alternatively, after reading up on the parent-child feature of ES, could
this be something I could use.

The way I look at this is I have a domain (i.e. blahblah.com), then under
this blahblah.com domain I could have many documents (i.e.
blahblah.com/somepage.html, blahblah.com/index.html,
blahblah.com/someotherpage.php).

Would making these document children work?

Therefore, could I search on children documents to return the parent
document?

Thanks again!--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Group-By-Field-Value-...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #5