Hi,
So, I've got a table with a fulltext index, and my client wants search terms to be exclusive (that is, all search terms MUST be included in the record, or the record should not appear in the search results). So I've got the query set up as a boolean-type query (because, AFAIK, that's the only way to have all search terms be required), where a search for, say, calcium oxide translates as a search for +calcium* +oxide* (they want to allow partial word matches).
So far, so good.
Now, in addition to that, my client would like sort preference given to exact phrase matches, without requiring exact phrase matches. So, for example, a search for:
acetate solution
should, again, only return search results with both "acetate" and "solution" somewhere in the results. Partial words are ok. It can also return LEAD ACETATE AQUEOUS SOLUTION... but that result should appear below all of the results that have the exact phrase, acetate solution. So it might return:
AMMONIUM ACETATE SOLUTION
CALCIUM ACETATE SOLUTION
MAGNESIUM ACETATE SOLUTION
SODIUM ACETATE SOLUTION
COPPER II ACETATE 3% AQUEOUS SOLUTION CUPRIC ACETATE
LEAD ACETATE AQUEOUS SOLUTION
SODIUM ACETATE BUFFER SOLUTION PH 5.2 +/- 0.05 AT 25 C MOLECULAR BIOLOGY REAGENT S7899
SODIUM ACETATE BUFFER SOLUTION PH 7.0 +/- 0.05 AT 250C MOLECULAR BIOLOGY REAGENT S2404
...in that order (that is, in order of whether there's an exact phrase match, and then in alphabetical order).
According to enclosing a search term in double-quotes makes an exact phrase required, not optional. So is this even possible, to require all search terms be present in the results, and allow partial word matches, and make exact phrases optional, and sort exact phrases first?
Thanks!
Katie
So, I've got a table with a fulltext index, and my client wants search terms to be exclusive (that is, all search terms MUST be included in the record, or the record should not appear in the search results). So I've got the query set up as a boolean-type query (because, AFAIK, that's the only way to have all search terms be required), where a search for, say, calcium oxide translates as a search for +calcium* +oxide* (they want to allow partial word matches).
So far, so good.
Now, in addition to that, my client would like sort preference given to exact phrase matches, without requiring exact phrase matches. So, for example, a search for:
acetate solution
should, again, only return search results with both "acetate" and "solution" somewhere in the results. Partial words are ok. It can also return LEAD ACETATE AQUEOUS SOLUTION... but that result should appear below all of the results that have the exact phrase, acetate solution. So it might return:
AMMONIUM ACETATE SOLUTION
CALCIUM ACETATE SOLUTION
MAGNESIUM ACETATE SOLUTION
SODIUM ACETATE SOLUTION
COPPER II ACETATE 3% AQUEOUS SOLUTION CUPRIC ACETATE
LEAD ACETATE AQUEOUS SOLUTION
SODIUM ACETATE BUFFER SOLUTION PH 5.2 +/- 0.05 AT 25 C MOLECULAR BIOLOGY REAGENT S7899
SODIUM ACETATE BUFFER SOLUTION PH 7.0 +/- 0.05 AT 250C MOLECULAR BIOLOGY REAGENT S2404
...in that order (that is, in order of whether there's an exact phrase match, and then in alphabetical order).
According to enclosing a search term in double-quotes makes an exact phrase required, not optional. So is this even possible, to require all search terms be present in the results, and allow partial word matches, and make exact phrases optional, and sort exact phrases first?
Thanks!
Katie