Skip to content

Commit

Permalink
FIX Use a single space by default for block delimiter in index.
Browse files Browse the repository at this point in the history
A single space is non-intrusive and will not require any changes within existing projects to avoid changes to the way content is indexed - but providing an option for configuring the delimiter can help avoid false-positive results in phrase queries.
  • Loading branch information
GuySartorelli committed Sep 20, 2021
1 parent df6e469 commit 770d1cb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Extensions/ElementalPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class ElementalPageExtension extends ElementalAreasExtension
'ElementalArea',
];

/**
* The delimiter to separate distinct elements in indexed content.
*
* When using the getElementsForSearch() method to index all elements in a single field,
* a custom delimiter can be used help to avoid false positive results for phrase queries.
*
* @config
* @var string
*/
private static $delimiter_for_indexed_elements = ' ';

/**
* Returns the contents of each ElementalArea has_one's markup for use in Solr or Elastic search indexing
*
Expand Down Expand Up @@ -59,7 +70,7 @@ public function getElementsForSearch()
// CMS layout can break on the response. (SilverStripe 4.1.1)
SSViewer::set_themes($oldThemes);
}
return implode(' ... ', $output);
return implode($this->config()->get('delimiter_for_indexed_elements'), $output);
}

public function MetaTags(&$tags)
Expand Down

0 comments on commit 770d1cb

Please sign in to comment.