Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,20 @@ public final ResultsWrapper<ContentDTO> siteWideSearch(
// Restrict content types
.includeContentTypes(contentTypes)

// High priority matches on untokenised search string
.searchFor(new SearchInField(Constants.ID_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE))
.searchFor(new SearchInField(Constants.TITLE_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE))
.searchFor(new SearchInField(Constants.SUBTITLE_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE))

// Fuzzy search term matches
.searchFor(new SearchInField(Constants.ID_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.FUZZY))
.priority(Priority.HIGH).strategy(Strategy.DEFAULT))
.searchFor(new SearchInField(Constants.TITLE_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.FUZZY))
.searchFor(new SearchInField(Constants.SUBTITLE_FIELDNAME, searchTerms)
Expand All @@ -361,7 +372,7 @@ public final ResultsWrapper<ContentDTO> siteWideSearch(
.searchFor(new SearchInField(Constants.TAGS_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.FUZZY))
.searchFor(new SearchInField(Constants.PRIORITISED_SEARCHABLE_CONTENT_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.FUZZY))
.strategy(Strategy.FUZZY))
.searchFor(new SearchInField(Constants.SEARCHABLE_CONTENT_FIELDNAME, searchTerms)
.strategy(Strategy.FUZZY))

Expand Down Expand Up @@ -451,10 +462,24 @@ public final ResultsWrapper<ContentDTO> questionSearch(
.searchFor(new SearchInField(Constants.TAGS_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.SUBSTRING))
.searchFor(new SearchInField(Constants.PRIORITISED_SEARCHABLE_CONTENT_FIELDNAME, searchTerms)
.priority(Priority.HIGH).strategy(Strategy.SUBSTRING))
.strategy(Strategy.SUBSTRING))
.searchFor(new SearchInField(Constants.SEARCHABLE_CONTENT_FIELDNAME, searchTerms)
.strategy(Strategy.SUBSTRING));

if (searchString != null && !searchString.isBlank()) {
// High priority matches on untokenised search string
searchInstructionBuilder
.searchFor(new SearchInField(Constants.ID_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE))
.searchFor(new SearchInField(Constants.TITLE_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE))
.searchFor(new SearchInField(Constants.SUBTITLE_FIELDNAME + "." +
Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX, Collections.singleton(searchString))
.priority(Priority.HIGH).strategy(Strategy.SIMPLE));
}

// FIXME: Make this and PageFacade agnostic
// It doesn't need to know about books, just have required tags
// It doesn't need to know about subject, field or topic, just have atLeastOne tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ElasticSearchIndexer extends ElasticSearchProvider {
@Inject
public ElasticSearchIndexer(RestHighLevelClient searchClient) {
super(searchClient);
rawFieldsListByType.put("content", Lists.newArrayList("id", "title"));
rawFieldsListByType.put("content", Lists.newArrayList("id", "title", "subtitle"));
rawFieldsListByType.put("school", Lists.newArrayList("urn"));
nestedFieldsByType.put("content", Lists.newArrayList("audience"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ public class IsaacSearchInstructionBuilder {
private static final float PRIORITY_CONTENT_BOOST = 5L;

private List<SearchInField> searchesInFields;
public static final Long NO_BOOST = 1L;
private static final Long NO_BOOST = 1L;
private static final Long FIELD_BOOST = 5L;
private static final Long FIELD_BOOST_FUZZY = 1L;
private static final Long WILDCARD_FIELD_BOOST = 1L;

private static final Long HIGH_PRIORITY_FIELD_BOOST = 10L;
private static final Long HIGH_PRIORITY_FIELD_BOOST_FUZZY = 3L;
private static final Long HIGH_PRIORITY_WILDCARD_FIELD_BOOST = 2L;
private static final Long HIGH_PRIORITY_FIELD_BOOST_FUZZY = 8L;
private static final Long HIGH_PRIORITY_WILDCARD_FIELD_BOOST = 5L;

private static final Long SEARCHABLE_CONTENT_FIELD_BOOST = 2L;

private static final Long EVENT_ADDRESS_FIELD_BOOST = 3L;
private static final Long EVENT_ADDRESS_FIELD_BOOST_FUZZY = 1L;
Expand Down Expand Up @@ -359,25 +361,28 @@ private void addSearchesInFieldsToInstruction(final BooleanInstruction instructi

} else if (searchInField.getStrategy() == Strategy.SUBSTRING) {
Long boost = searchInField.getPriority() == Priority.HIGH
? HIGH_PRIORITY_FIELD_BOOST : FIELD_BOOST;
? HIGH_PRIORITY_WILDCARD_FIELD_BOOST : WILDCARD_FIELD_BOOST;

generatedSubInstructions.add(
new MatchInstruction(searchInField.getField(), term, boost, false));
generatedSubInstructions.add(
new WildcardInstruction(searchInField.getField(), "*" + term + "*", boost));

} else if (searchInField.getStrategy() == Strategy.FUZZY) {
Long boost = searchInField.getPriority() == Priority.HIGH
? HIGH_PRIORITY_WILDCARD_FIELD_BOOST : WILDCARD_FIELD_BOOST;

boolean isSearchableContentField = searchInField.getField().equals(Constants.SEARCHABLE_CONTENT_FIELDNAME) ||
searchInField.getField().equals(Constants.PRIORITISED_SEARCHABLE_CONTENT_FIELDNAME);
Long boost = isSearchableContentField
? SEARCHABLE_CONTENT_FIELD_BOOST : searchInField.getPriority() == Priority.HIGH
? HIGH_PRIORITY_WILDCARD_FIELD_BOOST : WILDCARD_FIELD_BOOST;
generatedSubInstructions.add(new MatchInstruction(searchInField.getField(), term, boost, true));
generatedSubInstructions.add(
new WildcardInstruction(searchInField.getField(), "*" + term + "*", boost));
// Use a multi-match instruction, and ensure multi-match instructions for a particular term are
// grouped together
multiMatchSearchesGroupedByTerm.putIfAbsent(term, Sets.newHashSet());
multiMatchSearchesGroupedByTerm.get(term).add(searchInField.getField());

if (!isSearchableContentField) {
generatedSubInstructions.add(new WildcardInstruction(searchInField.getField(), "*" + term + "*", boost));
// Use a multi-match instruction, and ensure multi-match instructions for a
// particular term are grouped together
multiMatchSearchesGroupedByTerm.putIfAbsent(term, Sets.newHashSet());
multiMatchSearchesGroupedByTerm.get(term).add(searchInField.getField());
}

} else if (searchInField.getStrategy() == Strategy.SIMPLE) {
Long boost = searchInField.getPriority() == Priority.HIGH
? HIGH_PRIORITY_FIELD_BOOST : NO_BOOST;
Expand Down
Loading