Unified search across document types question?

I am trying to implement something similar to the unified search box of
last fm (http://ui-patterns.com/users/1/collections/554/entry/2961)
However I have some problems/issues.

let's say I have 3 document types (A, B and C) and I want to implement one
unified search box which returns results group by their document type (see
link above)

If I search in type A (/index/A/_search?q=someString* ) I get 1 hit:
If I search in type B (/index/B/_search?q=someString*) I get 108 hits.
By default only the top 10 hits are returned.

Now if I search in both document types (/index/A,B/_search?q=someString*) I
get 109 hits. It again only displays the top 10 hits.
However it only display hits from document type B and not the one from A.

Is there any easy way to return the same amount of hits for each document
type in one search?
Or do I have to do 3 distinct searches and then group them afterwards ? Can
facets help me here?

thanks in advance

Ümit

--

Perhaps Multi search is what you are looking for?

http://www.elasticsearch.org/guide/reference/api/multi-search.html

Does it help?

Le 19 novembre 2012 à 15:47, "Ümit Seren" uemit.seren@gmail.com a écrit :

I am trying to implement something similar to the unified search box of last
fm ( http://ui-patterns.com/users/1/collections/554/entry/2961
http://ui-patterns.com/users/1/collections/554/entry/2961 )
However I have some problems/issues.

let's say I have 3 document types (A, B and C) and I want to implement one
unified search box which returns results group by their document type (see
link above)

If I search in type A (/index/A/_search?q=someString* ) I get 1 hit:
If I search in type B (/index/B/_search?q=someString*) I get 108 hits.
By default only the top 10 hits are returned.

Now if I search in both document types (/index/A,B/_search?q=someString*) I
get 109 hits. It again only displays the top 10 hits.
However it only display hits from document type B and not the one from A.

Is there any easy way to return the same amount of hits for each document
type in one search?
Or do I have to do 3 distinct searches and then group them afterwards ? Can
facets help me here?

thanks in advance

Ümit

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

@David,
Ah thanks. I apparently missed that part about multi serach. I will look
into it. BTW are there some best practices for doing these kind of unified
search across document types (think one should be aware of or take care)?

On Mon, Nov 19, 2012 at 3:52 PM, David Pilato david@pilato.fr wrote:

**
Perhaps Multi search is what you are looking for?

http://www.elasticsearch.org/guide/reference/api/multi-search.html

Does it help?

Le 19 novembre 2012 à 15:47, "Ümit Seren" uemit.seren@gmail.com a
écrit :

I am trying to implement something similar to the unified search box of
last fm ( http://ui-patterns.com/users/1/collections/554/entry/2961)
However I have some problems/issues.

let's say I have 3 document types (A, B and C) and I want to implement one
unified search box which returns results group by their document type (see
link above)

If I search in type A (/index/A/_search?q=someString* ) I get 1 hit:
If I search in type B (/index/B/_search?q=someString*) I get 108 hits.
By default only the top 10 hits are returned.

Now if I search in both document types (/index/A,B/_search?q=someString*)
I get 109 hits. It again only displays the top 10 hits.
However it only display hits from document type B and not the one from
A.

Is there any easy way to return the same amount of hits for each document
type in one search?
Or do I have to do 3 distinct searches and then group them afterwards ?
Can facets help me here?

thanks in advance

Ümit

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--

The Multi-search solves my problem.
However using the JAVA API I ran into an issue with the returned hits.

I create a MutliSearchRequestBuilder and add 3 distinct
SearchRequestBuilders to it and I specify the size to be 10 (using
setSize()).
However they always return 50 hits no matter which size I specify.
Here is how the SearchRequestBuilder looks like:

{
"size" : 10,
"query" : {
"multi_match" : {
"query" : "some text",
"fields" : [ "field1","field"]
}
}
}

On Monday, November 19, 2012 3:52:45 PM UTC+1, David Pilato wrote:

Perhaps Multi search is what you are looking for?

http://www.elasticsearch.org/guide/reference/api/multi-search.html

Does it help?

Le 19 novembre 2012 à 15:47, "Ümit Seren" <uemit...@gmail.com<javascript:>>
a écrit :

I am trying to implement something similar to the unified search box of
last fm ( http://ui-patterns.com/users/1/collections/554/entry/2961)
However I have some problems/issues.

let's say I have 3 document types (A, B and C) and I want to implement one
unified search box which returns results group by their document type (see
link above)

If I search in type A (/index/A/_search?q=someString* ) I get 1 hit:
If I search in type B (/index/B/_search?q=someString*) I get 108 hits.
By default only the top 10 hits are returned.

Now if I search in both document types (/index/A,B/_search?q=someString*)
I get 109 hits. It again only displays the top 10 hits.
However it only display hits from document type B and not the one from
A.

Is there any easy way to return the same amount of hits for each document
type in one search?
Or do I have to do 3 distinct searches and then group them afterwards ?
Can facets help me here?

thanks in advance

Ümit

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Ok forgot my message.
I had set searchType by accident to QUERY_AND_FETCH instead of
QUERY_THEN_FETCH.

On Tue, Nov 20, 2012 at 5:17 PM, Ümit Seren uemit.seren@gmail.com wrote:

The Multi-search solves my problem.
However using the JAVA API I ran into an issue with the returned hits.

I create a MutliSearchRequestBuilder and add 3 distinct
SearchRequestBuilders to it and I specify the size to be 10 (using
setSize()).
However they always return 50 hits no matter which size I specify.
Here is how the SearchRequestBuilder looks like:

{
"size" : 10,
"query" : {
"multi_match" : {
"query" : "some text",
"fields" : [ "field1","field"]
}
}
}

On Monday, November 19, 2012 3:52:45 PM UTC+1, David Pilato wrote:

Perhaps Multi search is what you are looking for?

http://www.elasticsearch.org/**guide/reference/api/multi-**search.htmlhttp://www.elasticsearch.org/guide/reference/api/multi-search.html

Does it help?

Le 19 novembre 2012 à 15:47, "Ümit Seren" uemit...@gmail.com a écrit :

I am trying to implement something similar to the unified search box of
last fm ( http://ui-patterns.com/users/**1/collections/554/entry/2961http://ui-patterns.com/users/1/collections/554/entry/2961)

However I have some problems/issues.

let's say I have 3 document types (A, B and C) and I want to implement
one unified search box which returns results group by their document type
(see link above)

If I search in type A (/index/A/_search?q=*someString ) I get 1
hit:
If I search in type B (/index/B/_search?q=*someString) I get 108
hits.
By default only the top 10 hits are returned.

Now if I search in both document types (/index/A,B/_search?q=*someString)
I get 109 hits. It again only displays the top 10 hits.
However it only display hits from document type B and not the one from
A.

Is there any easy way to return the same amount of hits for each
document type in one search?
Or do I have to do 3 distinct searches and then group them afterwards ?
Can facets help me here?

thanks in advance

Ümit

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--