Skip to content

Commit

Permalink
Add a fuzzy structured query template.
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Jun 9, 2011
1 parent d84e030 commit b6e5e74
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/es/widgets.js
Expand Up @@ -1398,6 +1398,12 @@
highqual = row.find(".es-highqual").val();
if(lowqual.length) value[row.find(".es-lowop").val()] = lowqual;
if(highqual.length) value[row.find(".es-highop").val()] = highqual;
} else if(op === "fuzzy") {
var qual = row.find(".es-qual").val(),
fuzzyqual = row.find(".es-fuzzyqual").val();

if(qual.length) value["value"] = qual;
if(fuzzyqual.length) value[row.find(".es-fuzzyop").val()] = fuzzyqual;
} else {
value = row.find(".es-qual").val();
}
Expand All @@ -1424,7 +1430,7 @@
_changeQueryField_handler: function(jEv) {
var select = $(jEv.target);
var spec = select.children(":selected").data("spec");
select.siblings().remove(".es-op,.es-qual,.es-range");
select.siblings().remove(".es-op,.es-qual,.es-range,.es-fuzzy");
var ops = [];
if(spec.type === 'match_all') {
} else if(spec.type === '_all') {
Expand All @@ -1444,11 +1450,13 @@

_changeQueryOp_handler: function(jEv) {
var op = $(jEv.target), opv = op.val();
op.siblings().remove(".es-qual,.es-range");
if(opv === 'term' || opv === 'wildcard' || opv === 'prefix' || opv === 'fuzzy' || opv === "query_string") {
op.siblings().remove(".es-qual,.es-range,.es-fuzzy");
if(opv === 'term' || opv === 'wildcard' || opv === 'prefix' || opv === "query_string") {
op.after({ tag: "INPUT", cls: "es-qual", type: "text" })
} else if(opv === 'range') {
op.after(this._range_template());
} else if(opv === 'fuzzy') {
op.after(this._fuzzy_template());
}
},

Expand Down Expand Up @@ -1482,6 +1490,14 @@
{ tag: "SELECT", cls: "es-highop", children: ["to", "lt", "lte"].map(acx.ut.option_template) },
{ tag: "INPUT", type: "text", cls: "es-highqual" },
]};
},

_fuzzy_template: function() {
return { tag: "SPAN", cls: "es-fuzzy", children: [
{ tag: "INPUT", cls: "es-qual", type: "text" },
{ tag: "SELECT", cls: "es-fuzzyop", children: ["max_expansions", "min_similarity"].map(acx.ut.option_template) },
{ tag: "INPUT", cls: "es-fuzzyqual", type: "text" }
]};
}
});

Expand Down

0 comments on commit b6e5e74

Please sign in to comment.