Skip to content

Run Examples

Yann Barraud edited this page Dec 24, 2013 · 5 revisions

Without threshold

Request

{
  "size" : 4,
  "query" : {
    "custom_score" : {
      "query" : {
        "match_all" : { }
      },
      "script" : "entity-resolution",
      "lang" : "native",
      "params" : {
        "entity" : {
          "fields" : [ {
            "field" : "city",
            "value" : "South",
            "cleaners" : [ {
              "name" : "no.priv.garshol.duke.cleaners.TrimCleaner"
            }, {
              "name" : "no.priv.garshol.duke.cleaners.LowerCaseNormalizeCleaner"
            } ],
            "high" : 0.95,
            "comparator" : {
              "name" : "no.priv.garshol.duke.comparators.JaroWinkler"
            },
            "low" : 0.1
          }, {
            "field" : "state",
            "value" : "ME",
            "cleaners" : [ {
              "name" : "no.priv.garshol.duke.cleaners.LowerCaseNormalizeCleaner"
            } ],
            "high" : 0.95,
            "comparator" : {
              "name" : "no.priv.garshol.duke.comparators.JaroWinkler"
            },
            "low" : 0.1
          }, {
            "field" : "population",
            "value" : "26000",
            "cleaners" : [ {
              "name" : "no.priv.garshol.duke.cleaners.DigitsOnlyCleaner"
            } ],
            "high" : 0.95,
            "comparator" : {
              "name" : "no.priv.garshol.duke.comparators.NumericComparator"
            },
            "low" : 0.1
          }, {
            "field" : "position",
            "value" : "43,70",
            "cleaners" : [ {
              "name" : "no.priv.garshol.duke.cleaners.LowerCaseNormalizeCleaner"
            } ],
            "high" : 0.95,
            "comparator" : {
              "name" : "no.priv.garshol.duke.comparators.GeopositionComparator",
              "params" : {
                "max-distance" : "100"
              }
            },
            "low" : 0.1
          } ]
        }
      }
    }
  }
}

Response

{
  "took" : 151,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 10,
    "max_score" : 0.97579086,
    "hits" : [ {
      "_index" : "test",
      "_type" : "city",
      "_id" : "3",
      "_score" : 0.97579086, "_source" : {"city":"South Portland","state":"ME","population":25002,"position":"43.631549,70.272724"}
    }, {
      "_index" : "test",
      "_type" : "city",
      "_id" : "5",
      "_score" : 0.29081574, "_source" : {"city":"Portland","state":"ME","population":66194,"position":"43.665116,70.269086"}
    }, {
      "_index" : "test",
      "_type" : "city",
      "_id" : "10",
      "_score" : 0.057230186, "_source" : {"city":"Boston","state":"MA","population":617594,"position":"42.321597,71.089115"}
    }, {
      "_index" : "test",
      "_type" : "city",
      "_id" : "2",
      "_score" : 0.049316783, "_source" : {"city":"South Burlington","state":"VT","population":17904,"position":"44.451846,73.181710"}
    } ]
  }
}

With threshold && using stored configuration

Request

{
  "size": 4,
  "min_score" : 0.7,
  "query": {
    "custom_score": {
      "query": {
        "match_all": {}
      },
      "script": "entity-resolution",
      "lang": "native",
      "params": {
        "entity": {
          "configuration": {
            "index": "entity",
            "type": "entity-configuration",
            "name": "test"
          },
          "fields": [
            {
              "field": "city",
              "value": "South"
            },
            {
              "field": "state",
              "value": "ME"
            },
            {
              "field": "population",
              "value": "26000"
            },
            {
              "field": "position",
              "value": "43,70"
            }
          ]
        }
      }
    }
  }
}

Response

{
  "took" : 46,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.97579086,
    "hits" : [ {
      "_index" : "test",
      "_type" : "city",
      "_id" : "3",
      "_score" : 0.97579086, "_source" : {"city":"South Portland","state":"ME","population":25002,"position":"43.631549,70.272724"}
    } ]
  }
}

Clone this wiki locally