I am a bit new to Elasticsearch and I am wondering how it is possible to do a partial match of a query on a particular filed.
Lets say I have a field called "department" and it has a value "accounting". So when I search for something like "The accounting", I should be able to get the result.
eg:- Below are my two documents:
{
"name": "Joe",
"department": "finance"
},
{
"name": "Matt",
"department": "accounting"
}
My search query on the field department is The accounting or The accounting department and my expected result should be:
{
"name": "Matt",
"department": "accounting"
}
UPDATE:
@Russ Cam: The Standard analyzer removes all the punctuation and special characters so what if I have the value in the field department saved as dept/accounting and when i search for dept: the dept/accounting I should get those documents that have the department value as dept/accounting.
I don't want ES to give me documents with the department as dept/accounting when someone searches for dept or accounting. Is this possible?
Assume that the following are my documents in ES:
{
"name": "Matt",
"department": "dept/accounting"
},
{
"name": "Kate",
"department": "dept"
},
{
"name": "Adam",
"department": "accounting"
}
The user searches for dept and he gets:
{
"name": "Kate",
"department": "dept"
}
When the user searches for blah blah dept/accounting blah he should get only this:
{
"name": "Matt",
"department": "dept/accounting"
}
Have you tried match query ,this should work for you