My requirement is this:
If I pass multiple words for search as a list, ES will return documents with subset of word matches along with words matched So I can understand which document matched which subset.
Suppose I need to search for words such as Football, Cricket, Tennis, Golf etc. in three documents
I am going to store these files in corresponding documents. Mappings for "mydocuments" index looks like this:
{
"mydocuments" : {
"mappings" : {
"docs" : {
"properties" : {
"file_content" : {
"type" : "string"
}
}
}
}
}
}
First Document
{ _id: 1, file_content: "I love tennis and cricket"}
Second document:
{ _id: 2, file_content: "tennis and football are very popular"}
Third document:
{ _id: 3, file_content: "football and cricket are originated in england"}
I should be able to search a single file/or multiple files for Football, Tennis, cricket, golf and it should return something like this
Something like this
"hits":{
"total" : 3,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_source" : {
"file_content" : ["football","cricket"],
"postDate" : "2009-11-15T14:12:12",
}
},
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "2",
"_source" : {
"file_content" : ["football","tennis"],
"postDate" : "2009-11-15T14:12:12",
}
}
]
Or in case of multiple file searches an array of above search results
Any idea how can we do this using Elasticsearch?
If this really can not be done using elasticsearch I am ready to evaluate any other options (Native lucene, Solr)
EDIT
My bad probably I did not provide enough details. @Andrew what I meant by file is the text content of a file stored as a String Field (Full Text) in a document in ES. Assume One file corresponds to one document with text content string in a field called "file_content".
{football: yes, cricket: no, tennis : yes , golf no}
is about your application and ES cannot give you something like this. ES gives you JSON and this JSON has a certain, well determined structure. Please read the documentation about ES first, and then come up with a meaningful question about ES. – Andrei Stefan