my $highlight_min = int(shift || 0);
my $highlight_max = int(shift || 0);
my $short_word_length = shift;
+
+ my $normalization = int(shift || 14); # 14 is not totally arbitrary.
+ # See http://www.postgresql.org/docs/9.0/static/textsearch-controls.html#TEXTSEARCH-RANKING
+
my $limit = int(shift || 10);
$limit = 10 unless $limit > 0;
$search_class,
$headline_opts,
$org_unit,
- $limit
+ $limit,
+ $normalization
]
});
}
highlight_min
highlight_max
short_word_length
+ normalization
limit
)
);
search_class TEXT, -- 'alias' or 'class' or 'class|field..', etc
headline_opts TEXT, -- markup options for ts_headline()
visibility_org INTEGER,-- null if you don't want opac visibility test
- query_limit INTEGER -- use in LIMIT clause of interal query
+ query_limit INTEGER,-- use in LIMIT clause of interal query
+ normalization INTEGER -- argument to TS_RANK_CD()
) RETURNS TABLE (
value TEXT, -- plain
match TEXT, -- marked up
cmc.bouyant AND _registered.field_class IS NOT NULL,
_registered.field = cmf.id,
cmf.weight,
- TS_RANK_CD(mbe.index_vector, $1),
+ TS_RANK_CD(mbe.index_vector, $1, $6),
cmc.bouyant
FROM metabib.browse_entry_def_map mbedm
JOIN metabib.browse_entry mbe ON (mbe.id = mbedm.entry)
JOIN config.metabib_field cmf ON (cmf.id = mbedm.def)
JOIN config.metabib_class cmc ON (cmf.field_class = cmc.name)
- ' || search_class_join || opac_visibility_join || '
- WHERE $1 @@ mbe.index_vector
+ ' || search_class_join || opac_visibility_join ||
+ ' WHERE $1 @@ mbe.index_vector
ORDER BY 4 DESC, 5 DESC NULLS LAST, 6 DESC, 7 DESC, 8 DESC, 1 ASC
- LIMIT $5
- ' USING query, search_class, headline_opts, visibility_org, query_limit;
+ LIMIT $5'
+ USING
+ query, search_class, headline_opts,
+ visibility_org, query_limit, normalization
+ ;
-- sort order:
-- bouyant AND chosen class = match class
search_class TEXT, -- 'alias' or 'class' or 'class|field..', etc
headline_opts TEXT, -- markup options for ts_headline()
visibility_org INTEGER,-- null if you don't want opac visibility test
- query_limit INTEGER -- use in LIMIT clause of interal query
+ query_limit INTEGER,-- use in LIMIT clause of interal query
+ normalization INTEGER -- argument to TS_RANK_CD()
) RETURNS TABLE (
value TEXT, -- plain
match TEXT, -- marked up
cmc.bouyant AND _registered.field_class IS NOT NULL,
_registered.field = cmf.id,
cmf.weight,
- TS_RANK_CD(mbe.index_vector, $1),
+ TS_RANK_CD(mbe.index_vector, $1, $6),
cmc.bouyant
FROM metabib.browse_entry_def_map mbedm
JOIN metabib.browse_entry mbe ON (mbe.id = mbedm.entry)
JOIN config.metabib_field cmf ON (cmf.id = mbedm.def)
JOIN config.metabib_class cmc ON (cmf.field_class = cmc.name)
- ' || search_class_join || opac_visibility_join || '
- WHERE $1 @@ mbe.index_vector
+ ' || search_class_join || opac_visibility_join ||
+ ' WHERE $1 @@ mbe.index_vector
ORDER BY 4 DESC, 5 DESC NULLS LAST, 6 DESC, 7 DESC, 8 DESC, 1 ASC
- LIMIT $5
- ' USING query, search_class, headline_opts, visibility_org, query_limit;
+ LIMIT $5'
+ USING
+ query, search_class, headline_opts,
+ visibility_org, query_limit, normalization
+ ;
-- sort order:
-- bouyant AND chosen class = match class
dojo.declare(
"openils.AutoSuggestStore", null, {
- "limit": 10,
- "last_fetch": null,
- "org_unit_getter": null,
- "highlight_max": null,
- "highlight_min": null,
- "short_word_length": null,
+ "_last_fetch": null, /* used internally */
+
+ /* Everything between here and the constructor can be specified in
+ * the constructor's args object. */
+
+ "type_selector": null, /* HTMLSelect object w/ options whose values
+ are search_classes (required) */
+ "org_unit_getter": null, /* function that returns int (OU ID) */
+
+ "limit": 10, /* number of suggestions at once */
+ "highlight_max": null, /* TS_HEADLINE()'s MaxWords option */
+ "highlight_min": null, /* TS_HEADLINE()'s MinWords option */
+ "short_word_length": null, /* TS_HEADLINE()'s ShortWord option */
+ "normalization": null, /* TS_RANK_CD()'s normalization argument */
"constructor": function(/* object */ args) {
dojo.mixin(this, args); /* XXX very sloppy */
params.push("org_unit=" + this.org_unit_getter());
dojo.forEach(
- ["highlight_max", "highlight_min", "short_word_length"],
+ ["highlight_max", "highlight_min",
+ "short_word_length", "normalization"],
dojo.hitch(this, function(arg) {
if (this[arg] != null)
params.push(arg + "=" + this[arg]);
var self = this;
var process_fetch = function(obj, when) {
- if (when < self.last_fetch) /* Stale response. Discard. */
+ if (when < self._last_fetch) /* Stale response. Discard. */
return;
dojo.forEach(
if (typeof req.onBegin == "function")
req.onBegin.call(callback_scope, -1, req);
- var fetch_time = this.last_fetch = (new Date().getTime());
+ var fetch_time = this._last_fetch = (new Date().getTime());
dojo.xhrGet({
"url": url,