Question

i want my search return the exact match of my query string. Query String includes 2 words.

query :"general doctor" should return only general doctor not "doctor general"

Search method:

$lower = 'general doctor';

$query = new \Elastica\Query\MatchAll();

$tagquery = new \Elastica\Query\Match();
$tagquery->setDefaultField('branchslug');
$tagquery->setFieldBoost('branchslug', 10);
$tagquery->setQuery(mb_strtolower($lower, 'UTF-8'));

$tagfilter = new \Elastica\Filter\Nested();
$tagfilter->setPath('expertdetailbranchid');
$tagfilter->setQuery($tagquery);
$tagfilter->setCached();


$filterBoolArticle = new \Elastica\Filter\Bool();
$filterBoolArticle->addMust($tagfilter);
$filterBoolArticle->setCached();

index mapping: http://pastebin.com/JJkc9jq4

Was it helpful?

Solution

I solved problem.

$lower = '"general doctor"';

instead of

$lower = 'general doctor';

OTHER TIPS

I know you answered your own question, but this may be of use...

Lucene Query Syntax http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top