好的,我在弹性搜索中有这个文档,我只看一个字段用于短语前缀:
array(2) {
["query"]=>
array(1) {
["function_score"]=>
array(1) {
["query"]=>
array(1) {
["match"]=>
array(1) {
["program_name"]=>
array(3) {
["query"]=>
string(12) "microsoft wo"
["type"]=>
string(13) "phrase_prefix"
["analyzer"]=>
string(6) "simple"
}
}
}
}
}
["fields"]=>
array(1) {
[0]=>
string(1) "*"
}
}
现在,当我正在寻找" Microsoft Wor"我可以找到没有问题的Microsoft Word,但是,当我搜索Microsoft WO或Microsoft W时,我没有得到任何结果!
添加更多信息:
其他分析包括:
$objElasticIndex->create ( array (
'number_of_shards' => 1,
'number_of_replicas' => 1,
'analysis' => array (
'analyzer' => array (
'indexAnalyzer' => array (
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => array (
'lowercase'
)
),
'searchAnalyzer' => array (
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => array (
'standard',
'lowercase'
)
)
)
)
), true );
该字段的映射是:
// Set mapping
$mapping->setProperties ( array (
COL_PROGRAM_NAME => array (
'type' => 'string',
'include_in_all' => TRUE,
'boost' => 6.0,
'store' => true
),
这是完整的映射:
array(1) {
["software"]=>
array(6) {
["index_analyzer"]=>
string(13) "indexAnalyzer"
["search_analyzer"]=>
string(14) "searchAnalyzer"
["_all"]=>
array(1) {
["auto_boost"]=>
bool(true)
}
["_boost"]=>
array(1) {
["null_value"]=>
float(1)
}
["_source"]=>
array(1) {
["enabled"]=>
bool(false)
}
["properties"]=>
array(11) {
["description_45"]=>
array(3) {
["type"]=>
string(6) "string"
["store"]=>
bool(true)
["include_in_all"]=>
bool(true)
}
["id"]=>
array(3) {
["type"]=>
string(7) "integer"
["index"]=>
string(2) "no"
["include_in_all"]=>
bool(false)
}
["keywords"]=>
array(2) {
["type"]=>
string(6) "string"
["include_in_all"]=>
bool(true)
}
["program_name"]=>
array(4) {
["type"]=>
string(6) "string"
["boost"]=>
float(6)
["store"]=>
bool(true)
["include_in_all"]=>
bool(true)
}
}
}
}
我删除了一些字段以使其变小:)