0
votes

I have a rule from my SMEs for SOLR Search relevancy. It goes like this.

When words "XX", "YY", or "ZZ" are in the User's search terms, heavily boost the document_type "MMMM" in the results. (But ONLY then, which means I can't weight the doc itself I think.)

I can imagine building a "Query Pre-Processor" that checks for the presence of the specified terms "XX", etc. and then plugs them into a pre-built query that heavily boosts document_type "MMMM".

That feels more than a little clunky to me. Doing this in code and handling a "union" situation where terms from two rules are in the search doesn't sound like something I'd like to maintain.

I'm wondering if there could be a way to leverage SOLR to do this? The first thing that comes to mind is to put those particular search terms "XX", etc.. into any document_type "MMMM" when pre-processing the data to go into SOLR.

Just tossing them into the document's text is probably not going to change the weighting all that much -- especially if the term is in other documents NOT part of that document_type -- and that suggests to my mind an "important_abbreviations" field on all documents and a "standard" practice of including a boost for that general field on all queries. I say that because I don't recall ever seeing a way to boost a particular field within a doc except in a query.

I'm wondering if anyone else out there has solved this problem and if so, how -- since both of these feel a little clunky to me.

1
I used something like this for while using SOLR for Magento search ... But my method might not work for you since I used Magento's native indexing platform (that created the SOLR indexes) and modified the input. You can see what I am talking about here: stackoverflow.com/questions/12201991/…Zak
Could you use Query Elevation?MatsLindh
@MatsLindh - thanks for that suggestion. It would cover some cases I think, but the query could come in with several other terms and not just the "XX" I'll do a little more research on Query Elevation.jb62
@Zak - thanks! I'll go look at that.jb62

1 Answers

0
votes

Attempting One Possible Answer: Please feel free to critique, advise or warn.

(I'm aware that an "abbreviation" field feels a bit like synonyms, Please comment if you think synonyms would be a better way to approach this.)

Step 1: Make an "abbreviation" multivalued field in SOLR on all collection docs.

Step 2: Add "XX", "YY", "ZZ" to all documents of type "MMMM" when I build the solrInputDocument to send to SOLR.

Step 3: Boost the "abbreviation" field when adding the abbreviations in step 2 so that resulting xml looks like this:

<field name="abbreviation" boost="5.0">myXXAbbreviationGoesHere</field>

[Concern: Can I boost some fields of type "abbreviation" and not others? In other words, will SOLR respect/correctly calculate the field boost value if it's "2" on one document "5" on another and there is no boost on a 3rd document?]

Step 4: Do a copyField and drop "abbreviation" into the default "text" search field. [This probably looses me my field-specific weighting, yes? -- Thus 5 or 6 below.]

Step 5: OR - add a Request Handler that forces doing search on the abbreviations field directly on every incoming search. Not totally sure on this one, but I got the idea from this stackoverflow question: Solr - Boosting result if query is found in a special field

Step 6: OR - append the query text for searching "abbreviation" on every query entered in my UI - before submission to SOLR.

[In this case, I want to search the default field AND the "abbreviation" field with this single query. I assume that's possible, I just haven't tried to write the query yet. Comments gratefully accepted.]