Elasticsearch: Can it be used to avoid writing your own NLP? (e.g. Re-invent the wheel)
Elasticsearch "searching" is purely based on keyword searching.
What you get however is some NLP for e.g. retrieving or gather data, extracting the required information, tokenization, stopword removals(all these done by analyzer), similarity calculations (using tf-idf and vector space model).
Further NLP process consists of coming up with a model, training that model, classification of text data etc for which I do not think Elasticsearch has an engine that can do that (There is an implementation called MLT(More Like This) but I'm not sure how it works (haven't read it yet)).
What you can do is use elasticsearch as source for your NLP engine if you end up creating one, again for which, you do not need to implement the basic stages as mentioned above.
You can check this blog which is quite interesting.
Regardless, that being said and done, looking at your use case, I've come up with the below query. I know its not the exact solution but it would give the result you are looking for.
POST <your_index_name>/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "law",
"fields": [ "type", "place", "name"],
"type": "most_fields"
}
},
{
"multi_match": {
"query": "firm",
"fields": [ "type", "place", "name"],
"type": "most_fields"
}
},
{
"multi_match": {
"query": "boston",
"fields": [ "type", "place", "name"],
"type": "most_fields"
}
}
]
}
}
}
What I've done is simply made created a must clause for every word using the query you've posted. This would assure you that you don't end up getting the unwanted results you are looking for.
Let me know if it helps!