3

I'm trying to use ElasticSearch as a data store to find some people by their name. I've tried creating an index, I added words, changed mapping but when I'm trying to find people by name with the JaroWinkler & Levenstein algorithm, it gives nothing back.

step 1 PUT : http://127.0.0.1:9200/list

{
  "mappings": {
    "main": {
      "properties": {
        "ppl_name": {
          "type": "text"

        }
      }
    }
  }
}

with answer

{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "list"
}

step 2

post/put http://127.0.0.1:9200/list/main/1

{"ppl_name":"oleksandroleksandrovychborysenko"}

{"ppl_name":"oleksandr oleksandrovych borysenko"}

with answer

{
    "_index": "list",
    "_type": "main",
    "_id": "2",
    "_version": 1,
    "result": "created",
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    },
    "created": true
}

step 3 GET http://127.0.0.1:9200/list/_mapping answer :

 {
        "list": {
            "mappings": {
                "main": {
                    "properties": {
                        "ppl_name": {
                            "type": "text"
                        }
                    }
                }
            }
        }
    }

step 4 post http://127.0.0.1:9200/list/main/_search

with body

{
  "suggest": {
    "text" : "oleksandr oleksandrovych borysenko",
    "levenstein" : {
      "term" : {
              "string_distance": "levenstein",
        "field" : "ppl_name"
      }
    },
    "jarowinkler" : {
      "term" : {
        "string_distance": "jarowinkler",
        "field" : "ppl_name"
      }
    }
  }
}

and ANSWER

{
    "took": 28,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 0,
        "max_score": 0,
        "hits": []
    },
    "suggest": {
        "jarowinkler": [
            {
                "text": "oleksandr",
                "offset": 0,
                "length": 9,
                "options": []
            },
            {
                "text": "oleksandrovych",
                "offset": 10,
                "length": 14,
                "options": []
            },
            {
                "text": "borysenko",
                "offset": 25,
                "length": 9,
                "options": []
            }
        ],
        "levenstein": [
            {
                "text": "oleksandr",
                "offset": 0,
                "length": 9,
                "options": []
            },
            {
                "text": "oleksandrovych",
                "offset": 10,
                "length": 14,
                "options": []
            },
            {
                "text": "borysenko",
                "offset": 25,
                "length": 9,
                "options": []
            }
        ]
    }
}

Can anyone help me with this situation ?

  • "I'm trying to find people by name with the JaroWinkler & Levenstein algorithm, it gives nothing back": I'm a bit confused — you are asking for a `suggest` (and not a search) and the response contains results with `suggest`. Do you want to run a regular search query instead of the suggest or do you want to pick up results from the suggest? – xeraa Jun 10 '18 at 13:56
  • I want to compare the words that are stored with the words from the query. Maybe I did not understand correctly and do not correctly call SEARCH words by algorithms.Can you show an example? – Oleg Kuzminsky Jun 11 '18 at 12:23
  • Ok, let me rephrase: Can you add (to your original question) what you are expecting as the result? – xeraa Jun 12 '18 at 15:34

0 Answers0