Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

score value 0 #171

Open
TomonoriSoejima opened this issue Jun 25, 2024 · 0 comments
Open

score value 0 #171

TomonoriSoejima opened this issue Jun 25, 2024 · 0 comments

Comments

@TomonoriSoejima
Copy link
Owner

DELETE restaurants



PUT /restaurants
{
  "mappings": {
    "properties": {
      "restword": {
        "type": "keyword",
        "ignore_above": 4096
      },
      "base_name": {
        "type": "text"
      }
    }
  }
}


POST /restaurants/_bulk
{ "index": { "_id": "1" } }
{ "restword": "SVF162 PREF14", "base_name": "Restaurant A" }
{ "index": { "_id": "2" } }
{ "restword": "SVF237002 PREF14", "base_name": "Restaurant B" }
{ "index": { "_id": "3" } }
{ "restword": "SVF237003 PREF14", "base_name": "Restaurant C" }
{ "index": { "_id": "4" } }
{ "restword": "SVF162 SVF237002 PREF14", "base_name": "Restaurant D" }
{ "index": { "_id": "5" } }
{ "restword": "PREF14", "base_name": "Restaurant E" }
{ "index": { "_id": "6" } }
{ "restword": "SVF162 SVF237003 PREF14", "base_name": "Restaurant F" }
{ "index": { "_id": "7" } }
{ "restword": "SVF237002 SVF237003 PREF14", "base_name": "Restaurant G" }
{ "index": { "_id": "8" } }
{ "restword": "SVF162 SVF237002 SVF237003 PREF14", "base_name": "Restaurant H" }
{ "index": { "_id": "9" } }
{ "restword": "PREF14", "base_name": "Restaurant I" }
{ "index": { "_id": "10" } }
{ "restword": "SVF162 PREF14", "base_name": "Restaurant J" }




POST /restaurants/_search?pretty=true&error_trace=true&typed_keys=true&rest_total_hits_as_int=true
{
  "track_total_hits": true,
  "from": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "restword": {
              "value": "PREF14"
            }
          }
        }
      ]
    }
  },
  "size": 20,
  "sort": [
    {
      "_script": {
        "type": "number",
        "script": {
          "lang": "painless",
          "source": "String restword = doc['restword'].value; int count = 0; if(restword.contains('SVF162')){ count += 1; } if(restword.contains('SVF237002')){ count += 1; } if(restword.contains('SVF237003')){ count += 1; } return count;"
        },
        "order": "desc"
      }
    }
  ],
  "_source": {
    "includes": [
      "restword",
      "base_name"
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant