eZ Platform Discussions

FullText: Exact matches boosting

version2

#1

Any idea how to perform exact matches boosting. For example, if we perform a search with this Query Type based on Criterion\FullText:

$query->query = new Criterion\LogicalAnd( [
   new Criterion\Subtree($rootLocation->pathString),
   new Criterion\Visibility(Criterion\Visibility::VISIBLE),
   new Criterion\ContentTypeIdentifier(['product']),
   new Criterion\FullText(\sprintf('*%s*', $search)),
]

A search key word ezplatform should:

  1. have more score
  2. and should appear first

Than the ezplatform discuss key word.

Unfortunately, the actual solr configuration solr makes ezplatform appear lastt with the same score as ezplatform discuss.

I’m sure that we need to modify the schema.xml configuration

Any help would be appreciated.


#2

AFAIK text fields are by default treated as text in Solr which means it will be tokenized. So your text ‘ezplatform discuss’ will be broken in to 2 tokens: ‘ezplatform’ and ‘discuss’. So if you search for ‘ezplatform’ you will get all all content which has the word ‘ezplatform’. Some boosting based purrelt it text heuristics might occur if the word is mentioned more time in one document, etc.

If you want that your search finds exact matches of data in one single field (which I think you want from your post) then you would need to treat that field as string in Solr, not text, main difference being that string is not tokenized and is treated as one single token.


#3

In fact I’m trying to create the same thing that is mentionned here vhttps://github.com/Novactive/NovaeZSolrSearchExtraBundle/blob/master/doc/exact_match_boost.md


#4

Ok, if this fits then use it :slight_smile: