0

I use a wildcard query on fields indexed with a keyword analyzer. I want to find the following document

{
  title: "JavaScript beginner course",
  url: "https://youtube.com/xyz"
}

with these queries: *beginner course* and *youtube* (* are wildcards). This is working.

When I search for *Java*, the document above will also match. That's fine. However, I want to boost search results with exact word matches. Meaning, a document with Java in the title should have a higher search score.

Problem is, the keyword analyzer doesn't index each word separately. But I need the keyword analyzer, because otherwise *beginner course* wouldn't match in the example above.

Is there a way to achieve exact matching with wildcard search + a keyword analyzer?

Florian Walther
  • 6,237
  • 5
  • 46
  • 104

1 Answers1

1

By itself you can't boost full word matches in a wildcard query to my knowledge.

But you can always have another analyzer and another query in conjunction with your wildcard query. So you would have both wildcard with lucene.keyword and "Java*" as well as text with lucene.standard and "Java" in one query.

oli
  • 659
  • 1
  • 6
  • 18