0

for my app i use the flashlight searchengine, in my elastic table i store a data with two fields id: { name: "", uid: "" }. when i want to retrive certain value i want to do a partial match only in the name field and retrive all two fields if the match work. in my request data usually i store this structure

search : {
  request: {
    -54shdjwirjghcb7364gf92jcns20ahd: {
        index: "firebase",
        type: "event",
        from: 0,
        size: 50,
        query: "*fra*"
    }
  }
}

the result is positive but, in this case flashlight search the partial match in all fields because if i do a match with a partial uid or a partial name the result is always positive (if the string correspond).

how can i do a partial match only for one field?

my server side search queue is this

_process: function (snap) {
        var dat = snap.val();
        var key = snap.key;

        if (this._assertValidSearch(key, dat)) {
            // Perform (a very simple) ElasticSearch query
            this.esc.search({
                index: dat.index,
                type: dat.type,
                from : dat.query.from,
                size : dat.query.size,
                q: dat.query
            }, function (error, response) {
                if (error) {
                    this._reply(key, { error: error, total: 0 });
                } else {
                    this._reply(key, response);
                }
            }.bind(this));
        }
    },

thanks in advance

DThink
  • 429
  • 2
  • 18

1 Answers1

0

Try using "name:*fra*" as the query. The query property is passed through to elasticsearch as the q parameter.

Check here: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-search.html

stevens32
  • 314
  • 3
  • 8