Sort order with 4 conditions that included geo_point and japanese characters


(Lộc) #1

I have some documents of shops like below. How can i get query to:

  1. Descending order of number_fans at shops
  2. Descending order of number_articles at shops
  3. Close from the current position order
  4. Japanese alphabet order

Indexing data

curl -XPUT "localhost:9200/shops/doc/1" -H 'Content-Type: application/json' -d'  
{
   "id": 1,
   "name": "中村 裕美子",
   "furigana_name": "木村 稔",
   "number_fans": 4,
   "number_articles": 1,
   "group_name": "有限会社 伊藤",
   "location": {
        "lat": 35.1284,
        "lon": 137.1446
   }
}

curl -XPUT "localhost:9200/shops/doc/2" -H 'Content-Type: application/json' -d'  
{
    "id": 2,
    "name": "山田 明美",
    "furigana_name": "木村 稔",
    "number_fans": 3,
    "number_articles": 2,
    "group_name": "有限会社 佐藤",
    "location": {
          "lat": 35.1177,
         "lon": 137.1915
    }
}

 curl -XPUT "localhost:9200/shops/doc/3" -H 'Content-Type: application/json' -d'  
{
     "id": 3,
     "name": "松本 晃",
     "furigana_name": "松本 裕美子",
     "number_fans": 3,
     "number_articles": 3,
     "group_name": "株式会社 青山",
     "location": {
           "lat": 35.1098,
          "lon": 137.4242
     }
 }

This is my query but i don't know how to filter japanese alphabet characters order and not sure is correct order for other.

curl -XPOST "localhost:9200/shops/_search" -H 'Content-Type: application/json' -d'  
{
      "query": {
            "match_all" : {}
       },
      "sort": [
                      { "number_fans": { "order": "desc" } },
                      { "number_articles": { "order": "desc" } },
                      { "_geo_distance" : {
                            "location": {
                                  "lat": 35.13914,
                                  "lon": 137.18779
                             },
                            "order" : "desc",
                            "unit" : "km"
                             }
                     }
               ],
        "size": 200
 }

I have added this question in stackoverflow, you can found in here: https://stackoverflow.com/questions/52724454/sort-order-with-4-conditions-that-included-geo-point-and-japanese-characters-by


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.