Помогите пожалуйста с запросом, есть имена и простой запрос по них
$request = array(
"from" => 0,
"size"=>1000000,
"query"=> array(
"match"=>array(
"full_description"=>array(
"query"=>$text,
"fuzziness"=> 2,
"prefix_length"=> 1,
)
)
);
но когда вбиваеш Иванов оно выдает первым Иванцов, потом Иванов а уже потом все остальное. Почему _score у Иванцова больше чем у Иванова? Пробовал анализаторы, ну код вот такой у меня: Создание индекса
$request = array(
"mappings"=> array(
"person"=>array(
"properties"=>array(
"id"=>array(
"type"=> "integer",
"index"=> "not_analyzed"
),
"updated"=>array(
"type"=> "date",
"index"=> "not_analyzed"
),
"full_description"=>array(
"type"=> "string"
)
)
)
));
Выборка из БД плагином jdbc
$request = array("type" => "jdbc",
"jdbc"=>array(
"url" => "jdbc:mysql://localhost:3306/test_m",
"user" => "user",
"password" => "pass",
"sql" => "SELECT id, updated, full_description FROM product_info",
"index"=>"index1",
"type"=>"person"
),
"analysis"=>array(
"analyzer"=> "russian"
)
);
Поиск, что закомичено я уже пробовал, ничего не помогает:
$request = array(
"from" => 0,
"size"=>1000000,
"query"=> array(
//"match_all"=>array(""=>""),
"match"=>array(
"full_description"=>array(
//"query"=> mb_convert_encoding($text, "utf-8", "CP1251"), //геморой с кодировками, еластик принимает utf-8
"query"=>$text,
"fuzziness"=> 2,
"prefix_length"=> 1,
//"min_similarity"=> "0.5"
)
)/*,
"order"=>array(
"max_score"=> "desc"
)*/
)/*,
"analysis"=>array(
"analyzer"=> "russian"
)*/
/*,
"sort"=>array(
"updated"=>array(
"order"=>"desc",
"ignore_unmapped" => "true"
)
)*/
);
Find results:
[0] => Array (
[_index] => index1
[_type] => person
[_id] => AUzbnYZoelMWbrisONZE
[_score] => 1.5704145
[_source] => Array
(
[id] => 12713
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванцов Р.Б. 1:1926 2:1960 текст
)
)
.....
[507] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnZ1PelMWbrisOVyj
[_score] => 0.9315139
[_source] => Array
(
[id] => 47112
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Инин Г.П. 1:1991 2:2013 текст
)
)
.....
[884] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnaQLelMWbrisOXNm
[_score] => 0.7421299
[_source] => Array
(
[id] => 52939
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванов М.А. 1:1919 2:1961 текст
)
)
........
[8190] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnYFaelMWbrisOLb0
[_score] => 0.39577943
[_source] => Array
(
[id] => 4697
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванова Д.А. 1:1912 2:1954 текст
)
)
.......
[8927] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbn2LBelMWbrisQj8R
[_score] => 0.3298162
[_source] => Array
(
[id] => 629366
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванова-Каменская М.О. 1:1989 2:2003 текст
)
)
Даю запрос с сортировкой и снова какой то бред:
$request = array(
"from" => 0,
"size"=>1000000,
"query"=> array(
"match"=>array(
"full_description"=>array(
"query"=>$text,
"fuzziness"=> 2,
"prefix_length"=> 1
)
)
),
"sort"=>array(
"full_description"=>array(
"order"=>"desc",
"ignore_unmapped" => "true"
)
)
);
[1] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnYFQelMWbrisOKb6
[_score] =>
[_source] => Array
(
[id] => 607
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванов Л.А. 1:1918 2:1960 текст
)
[sort] => Array
(
[0] => текст
)
)
[2] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnYFQelMWbrisOKcB
[_score] =>
[_source] => Array
(
[id] => 614
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванова-Каменская Л.А. 1:1918 2:1960 текст
)
[sort] => Array
(
[0] => текст
)
)
[3] => Array
(
[_index] => index1
[_type] => person
[_id] => AUzbnYFRelMWbrisOKiC
[_score] =>
[_source] => Array
(
[id] => 999
[updated] => 2015-04-12T00:52:00.000-04:00
[full_description] => Иванов Л.А. 1:1918 2:1960 текст
)
[sort] => Array
(
[0] => текст
)
)
Помогите люди добрые, думаю создать мультизапрос, первый по точному значению, а второй з фузинес 2, не будут результаты повторяться?
analyzed
-строках. Нужно делать специальный маппинг, чтобы в индексе сохранялась исходная строка, пригодная для сортировки. Гуглить по словам "String Sorting and Multifields".