1. ////////////////////////FOR JSON //////////////////////////
    2. {
    3. "fuzzy_like_this" : {
    4. "fields" : ["name.first", "name.last"],
    5. "like_text" : "text like this one",
    6. "max_query_terms" : 12
    7. }
    8. }
    9. /////////////////////////FOR PHP ///////////////////////////
    10. $query = new \Elastica\Query\Match();
    11. $query->setFieldQuery('article.title', $articleSearch->getTitle());
    12. $query->setFieldFuzziness('article.title', 0.7);
    13. $query->setFieldMinimumShouldMatch('article.title', '80%');
    14. /////////////////////////FOR PHP ///////////////////////////
    15. /*
    16. //模糊查询
    17. $arr[] = array(
    18. 'match'=>array(
    19. "txt"=>$_POST['Keyword'],//txt
    20. ),
    21. );
    22. //$es_query->setHighlight(array('txt'));
    23. //<span style="color:red">test</span>//txt
    24. $es_query->setHighlight(array(
    25. 'pre_tags' => array('<span style="color:red">'),
    26. 'post_tags' => array('</span>'),
    27. 'fields' => array(
    28. 'txt' => array(
    29. 'fragment_size' => 200,
    30. 'number_of_fragments' => 1,
    31. ),
    32. ),
    33. ));
    34. */