2017-10-05 119 views
0

我想elasticsearch搜索並顯示出與PHP的結果。我想使部分匹配就像是在MySQL例如:PHP elasticsearch部分匹配

$params = [ 
    'index' => 'my_index', 
    'type' => 'my_type', 
    'body' => [ 
     'query' => [ 
      'match' => [ 
       'title' => '.*abc.*' 
      ] 
     ] 
    ] 
]; 
+0

您需要以不同方式標記字段。 (東西NGRAM過濾器) 檢查此鏈接 https://www.elastic.co/guide/en/elasticsearch/guide/current/ngrams-compound-words.html – Vigikaran

+0

發表您的指標設置中,映射更明確的答案 – Vigikaran

回答

0

我用的是「匹配」,而不是「正則表達式」

$params = [ 
    'index' => 'my_index', 
    'type' => 'my_type', 
    'body' => [ 
     'query' => [ 
      'regexp' => [ 
       'title' => '.*abc.*' 
      ] 
     ] 
    ] 
]; 

select * from table_name where title like '%abc%' 

但我不`噸的工作守則