Please suggest how to achieve following with elasticsearch

Hi all,

I have a unique problem to solve, need your suggestion to solve that.

Index Requirement :

  1. i need to index response with multiple titles with one unique response
    id.

Search Requirement:

  1. i need to search some response title text and need to return say 30 or
    some defined count of response id with the most matched response title
  2. return will only have response Id and most matched title.

Please suggest how should i index and create a query for the same.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hiya

I suggest providing some examples of what your documents might look like
and what the search results might look like. That'd make it easier to
make suggestions about how to design a solution

clint

I have a unique problem to solve, need your suggestion to solve that.

Index Requirement :

  1. i need to index response with multiple titles with one unique
    response id.

Search Requirement:

  1. i need to search some response title text and need to return say 30
    or some defined count of response id with the most matched response
    title
  2. return will only have response Id and most matched title.

Please suggest how should i index and create a query for the same.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Three sample document

{
response_id : "1001",
response_title: ["response title 1"," response title 2 hello "]
}

{
response_id : "1002",
response_title: ["Hello response title 1 Hello hello"," response title 2
hello "]
}

{
response_id : "1003",
response_title: ["response title 1"," response title 2"]
}

if i search Hello i need output

[
{response_id:"1001", response: "response title 2 hello"},
{response_id : "1002", "Hello response title 1 Hello hello"} ** Return only
one title here with the most matched title only
]

On Monday, February 25, 2013 4:27:10 PM UTC+5:30, Clinton Gormley wrote:

Hiya

I suggest providing some examples of what your documents might look like
and what the search results might look like. That'd make it easier to
make suggestions about how to design a solution

clint

I have a unique problem to solve, need your suggestion to solve that.

Index Requirement :

  1. i need to index response with multiple titles with one unique
    response id.

Search Requirement:

  1. i need to search some response title text and need to return say 30
    or some defined count of response id with the most matched response
    title
  2. return will only have response Id and most matched title.

Please suggest how should i index and create a query for the same.

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hiya

if i search Hello i need output

[
{response_id:"1001", response: "response title 2 hello"},
{response_id : "1002", "Hello response title 1 Hello hello"} ** Return
only one title here with the most matched title only

There isn't a clear general solution for this. When you search, it
returns the matching document, rather than just the parts of the
document that matched.

That said, in this case, you can use highlighting to return the best
matching title.

Create the index - Note, we use the position_offset_gap to separate

the individual titles by 1000 words, otherwise

["title one","title two"] would be indexed as "title one title two"

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"test" : {
"properties" : {
"response_title" : {
"position_offset_gap" : 1000,
"type" : "string"
}
}
}
}
}
'

Index some data:

curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1' -d '
{
"response_id" : "1001",
"response_title" : [
"response title 1",
" response title 2 hello "
]
}
'
curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1' -d '
{
"response_id" : "1002",
"response_title" : [
"Hello response title 1 Hello hello",
" response title 2 hello "
]
}
'
curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1' -d '
{
"response_id" : "1003",
"response_title" : [
"response title 1",
" response title 2"
]
}
'

Search the data with highlighting, and number_of_fragments = 1

and fragment_size = 1000 (so that there is no overlap between titles)

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"match" : {
"response_title" : "Hello"
}
},
"highlight" : {
"fragment_size" : 1000,
"fields" : {
"response_title" : {}
},
"post_tags" : [
""
],
"pre_tags" : [
""
],
"number_of_fragments" : 1
}
}
'

[Mon Feb 25 14:16:46 2013] Response:

{

"hits" : {

"hits" : [

{

"_source" : {

"response_id" : "1002",

"response_title" : [

"Hello response title 1 Hello hello",

" response title 2 hello "

]

},

"_score" : 0.625,

"_index" : "test",

"_id" : "MFXGNXZXTpm1ZbsHSpD0Yw",

"_type" : "test",

"highlight" : {

"response_title" : [

"Hello response title 1 Hello hello"

]

}

},

{

"_source" : {

"response_id" : "1001",

"response_title" : [

"response title 1",

" response title 2 hello "

]

},

"_score" : 0.11506981,

"_index" : "test",

"_id" : "1V6H_lS8TMyxhrKieSxaDQ",

"_type" : "test",

"highlight" : {

"response_title" : [

" response title 2 hello "

]

}

}

],

"max_score" : 0.625,

"total" : 2

},

"timed_out" : false,

"_shards" : {

"failed" : 0,

"successful" : 5,

"total" : 5

},

"took" : 6

}

clint

--
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.
For more options, visit https://groups.google.com/groups/opt_out.