Hi Jingang,
Here is a full example with the index settings and mappings and a curl
command to show how various forms of Gates may be indexed so that they
match each other without any additional work on the part of your query:
Analyzing the string using the "cn" field in the "test" index:
$ curl 'http://localhost:9200/test/_analyze?field=cn&pretty=true' -d "gates
gate's gates' gates's" && echo
{
"tokens" : [ {
"token" : "gate",
"start_offset" : 0,
"end_offset" : 5,
"type" : "",
"position" : 1
}, {
"token" : "gate",
"start_offset" : 6,
"end_offset" : 12,
"type" : "",
"position" : 2
}, {
"token" : "gate",
"start_offset" : 13,
"end_offset" : 18,
"type" : "",
"position" : 3
}, {
"token" : "gate",
"start_offset" : 20,
"end_offset" : 27,
"type" : "",
"position" : 4
} ]
}
And here are a subset of the settings and mappings. Note that I needed to
fully construct my own filter and analyzers in order to more fully specify
things such as the language to use.
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"refresh_interval" : "2s",
"number_of_replicas" : 0,
"analysis" : {
"filter" : {
"english_snowball_filter" : {
"type" : "snowball",
"language" : "English"
}
},
"analyzer" : {
"english_stemming_analyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : [ "standard", "lowercase", "asciifolding",
"english_snowball_filter" ]
},
"english_standard_analyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : [ "standard", "lowercase", "asciifolding" ]
}
}
}
}
},
"mappings" : {
"person" : {
"_all" : {
"enabled" : false
},
"properties" : {
"uid" : {
"type" : "long"
},
"cn" : {
"type" : "multi_field",
"fields" : {
"cn" : {
"type" : "string",
"analyzer" : "english_stemming_analyzer"
},
"raw" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"location" : {
"type" : "geo_point",
"lat_lon" : true
},
"telno" : {
"type" : "multi_field",
"fields" : {
"telno" : {
"type" : "string",
"analyzer" : "english_standard_analyzer"
},
"num" : {
"type" : "long"
}
}
},
"date" : {
"type" : "date",
"format" : "dateOptionalTime"
}
}
}
}
}
Hope this helps!
Regards,
Brian
On Monday, May 13, 2013 5:20:14 AM UTC-4, Jingang Wang wrote:
Hi there,
I want to use ES to query some documents mentioning some person names.
For example, when I use Bill Gates to conduct a matchPhraseQuery, I can
just get the documents exactly mention the name "Bill Gates".
While a lot of documents mention Bill Gates indirectly, say, they may
mention "Bill Gates's company".
How should I construct a query to retrieve these documents? Thanks.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.