How to search over all fields and return every document containing that search in elasticsearch?

I have a problem regarding searching in elasticsearch.
I have a index with multiple documents with several fields. I want to be able to search over all the fields running a query and want it to return all the documents that contains the value specified in the query. I Found that using simple_query_string worked well for this. However, it does not return consistent results. In my index I have documents with several fields that contain dates. For example:

"revisionDate" : "2008-01-01T00:00:00",
"projectSmirCreationDate" : "2008-07-01T00:00:00",
"changedDate" : "1971-01-01T00:00:00",
"dueDate" : "0001-01-01T00:00:00",

Those are just a few examples, however when I index for example:

GET new_document-20_v2/_search
{
  "size": 1000, 
  "query": {
    "simple_query_string" : {
        "query": "2008"
    }
  }
}

It only returns two documents, this is a problem because I have much more documents than just two that contains the value "2008" in their fields.

I also have problem searching file names.
In my index there are fields that contain fileNames like this:

"fileName" : "testPDF.pdf",
"fileName" : "demo.pdf",
"fileName" : "demo.txt",

When i query:

GET new_document-20_v2/_search
{
  "size": 1000, 
  "query": {
    "simple_query_string" : {
        "query": "demo"
    }
  }
}

I get no results
But if i query:

GET new_document-20_v2/_search
{
  "size": 1000, 
  "query": {
    "simple_query_string" : {
        "query": "demo.txt"
    }
  }
}

I get the proper result.

Is there any better way to search across all documents and fields than I did? I want it to return all the document matching the query and not just two or zero.
Any help would be greatly appreciated.

What is the output from _cat/indices/YOUR-INDEX?v?

I figured this out, ESCoder over on stackoverflow helped me out! Here is a link to soulution kibana - How to search over all fields and return every document containing that search in elasticsearch? - Stack Overflow

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.