1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| $es_text1 = new Elastica_Query_Text();
$es_text1 -> setField("title", "hello");
$es_text2 = new Elastica_Query_Text();
$es_text2 -> setField("post_text", "hello");
$es_child = new Elastica_Query_HasChild($es_text2, "post");
$es_bool = new Elastica_Query_Bool();
$es_bool ->addShould($es_text1);
$es_bool ->addShould($es_child);
$es_query = new Elastica_Query($es_bool);
$q = $es_query->toArray();
echo json_encode($q);
$es_search = new Elastica_Search($elastica_client);
$rs = $es_search->addIndex('forum')->search($es_query, 10);
|