0

私のアプリケーションでは mongoosastic を使用しています。マッピングとスキーマを作成しましたが、マッピング結果を見ると、場所のgeo_pointプロパティがオブジェクト タイプに変更されるため、クエリを使用して検索するとエラーが発生する可能性があります。

エラー:ネスト: QueryParsingException[[userprofiles] geo_point フィールド [location] が見つかりませんでした]; }]"

事前に残りのクライアントにクエリを実行します

マッピングの作成:

"mappings": {
        "userprofile": {
            "properties": {
                "address": {
                    "type": "string"
                },
                "timing": {
                    "type": "object",
                    "properties": {
                        "open": {
                            "type": "string"
                        },
                        "close": {
                            "type": "string"
                        }
                    },
                    "location": {
                        "type": "geo_point"
                    }

                }
            }
        }
    }

ユーザースキーマ

var UserProfileSchema = new Schema({
    userId: String,
    username: String,
    address: {
        type: String,
        es_indexed: true
    },
    number: {
        type: Number,
        es_indexed: true
    },
    location: {
        lat: Number,
        lon: Number
    },
    timing: {
        open: String,
        close: String
    }
});

検索クエリー :

{
  "query": {
    "filtered" : {
        "query" : {
            "match_all" : {}
        },
        "filter" : {
            "geo_distance" : {
                "distance" : "20km",
                "location" : {
                    "lat" : 37.9174,
                    "lon" : -122.3050
                }
            }
        }
    }
  }
}

4

1 に答える 1