Search via Query String DSL


(Nhat Nguyen) #1

Hi all, I'm using the query like that

GET _search
{
"query": {
"query_string": {
"query": "curator"
}
}
}
==> returned 3 items

GET _search
{
"query": {
"query_string": {
"query": "curato"
}
}
}
==> returned 0 item

GET _search
{
"query": {
"query_string": {
"query": "curat"
}
}
}
==> returned 3 items

I don't know what are differences between 3 keywords "curator", "curato" and "curat" ==> should return 3 items as expected. Any suggestions or explanations for these cases?

Thanks


(Luca Cavanna) #2

With your query you are looking for the exact terms "curator", "curato" or "curat". Whether you have those terms in your index or not depends on your data and how you indexed it (analysis chain).

Are you rather looking for anything that starts with "curat" ?


(Nhat Nguyen) #3

I limited the query with only field
"fields": [
"PostText"
],

and data source only have 3 documents
"PostText": "curator post",
"PostText": "abc 4 curator post",
"PostText": "curator post 2",

even I used wildcard for search string but the result is not good
GET _search
{
"query": {
"query_string": {
"fields": [
"PostText"
],
"query": "STARcuratoSTAR", ==> STAR: *
"analyze_wildcard": true
}
}
}
==> returned 0 item

I set analyzer like that:
var indexSettings={
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "smartcn"
}
}
}
}
};

is it ok?


(Luca Cavanna) #4

Ok, I think that means you want to do partial search, and using wildcards is one away, but there are others way too. First of all though, could you explain what your usecase is, just to verify that you indeed need partial search?

Thanks


(Nhat Nguyen) #5

@javanna thanks for your quick reply, after had a look more carefully I think the problem come from smartcn analyzer, more details


(system) #6