Searching all fields

Hi All,

I am new to elastic search and need some help from you. Below i a trying to explain the problem i face. Please help if you have any solution.

Below is my index sample

Index name - 'Location' - 4 fields - country, state, place, postal code
Index name - customer - 2 field - customer name, customer id

I have a single search box and i want to search both indexes. Below is my search query sample

{"query":{"multi_match":{"fields": [ "country", "state",''place'', "postal_Code", "Customer name", "Customer id"],"query":"user input goes here","type":"phrase_prefix"}}}

place can consist of multiple words - for example - "rob samson statue junction"

Hi soorajhere,

could you describe the problem you have with this query? Is it throwing and error? Does it return the wrong kind of documents? Also in the later case, can you provide a small example with a few documents in your index and try to explain which ones you are trying to retrieve and which not?

Hi cbuescher,

Thanks for your reply.
The issue which i face is that, the search behaves differently in two different environments. In development i have around 4k records, i am able to search 1st word, 2nd word, combination of first space second , combination of 2nd space 3rd etc. But in another server which has same indexes and same search query, i am unable to get records after searching.
What is mean is when i provide 1st word, i get matching records. Then keeping the first word there, i try a combination of first word+first letter of second word, its not giving me records even though there is a matching record present. This works fine in first server, but is not working in the second server.

Then i tried first word +first two letters from second server, still it didnt give any records. Same query worked fine with first server. Then i tried first word+ first three letters from second word, not it works! so i am not able to figure out why this works in one machine and not in another machine which has same index names, same yml and same search query.

Please help in case you have come across any such issues.

Hi,

if your query works on cluster1, and not on cluster2, I assume they run the same version and you have indexed the same data. In that case I would have a look at the mappings in the two target indices on both servers and figure out if there is any difference. It would be helpful if you could post those mappings and maybe one example document & a query that matches that doc in case 1 but not in case 2.

Hi Christoph Büscher,

Thank you for your reply.

The mappings in both the servers are exactly similar. Both uses similar YML file and uses filter Synonym. Both uses standard tokenizer.

{
"employeelocations": {
"settings": {
"index": {
"mappings": {
"location": {
"properties": {
"LocationDetails": {
"type": "string",
"analyzer": "synonym"
}

                 }
              }
           }
        },
        "number_of_shards": "5",
        "creation_date": "1461061314247",
        "analysis": {
           "filter": {
              "synonym": {
                 "ignore_case": "true",
                 "type": "synonym",
                 "synonyms": [
                    "pq=>port quarters",
                    "admin=>administration",
                    
                 ]
              }
           },
           "analyzer": {
              "synonym": {
                 "filter": [
                    "lowercase",
                    "synonym"
                 ],
                 "tokenizer": "standard"
              }
           }
        },
        "number_of_replicas": "1",
        "uuid": "S_aZYalAT1eYDUYiczUNqg",
        "version": {
           "created": "2010199"
        }
     }
  }

}
}

Only difference which i see between both the environment is one is having 4k records (the one which returns me result with first letter of second word) and other one is having 1.9 lakh records.

The field (LocationDetails) which is showing the issue is actually a string field which can contain 3 or 4 words, For example

"The port way 21B Avenue mansion 320021"

This field when i search using the above mentioned query is returning different results in both servers. When i type "The Port Way", i see 10 records like

The port way 1 Avenue mansion 320021
The port way 1A Avenue mansion 320021
The port way 1B Avenue mansion 320021
The port way 1C Avenue mansion 320021

The port way 2 Avenue mansion 320021
The port way 2A Avenue mansion 320021
The port way 2B Avenue mansion 320021
The port way 2C Avenue mansion 320021
The port way 3 Avenue mansion 320021
The port way 3C Avenue mansion 320021

in both the servers.

Now i am typing 1 along with "The port way". So the query which i pass to search is

"The port way 1". This should actually filter the result set so that 4 records from above result set is matching and it should be returned. But that is not happening in one of the server. It sometimes return no records, sometimes it returns only one matching record, while the other server gives me exactly filtered 4 records.

I am bit confused as ES behaves differently in different servers. Please help or provide me best way to achieve this in case i am doing it wrong.

Requirement is actually user should be able to search this field and search results should filter properly when user keeps typing one letter after the other, so that only one record will exist in search result when user reaches till last letter.