映射
[
"crushlings" => [
"mappings" => [
"user_profiles" => [
"properties" => [
"about_me" => [
"type" => "string",
"analyzer" => "standard",
],
"created_at" => [
"type" => "string",
],
"dob" => [
"type" => "date",
"format" => "yyyy-MM-dd",
],
"first_name" => [
"type" => "string",
"analyzer" => "standard",
],
"flagged" => [
"type" => "integer",
],
"gender" => [
"type" => "integer",
],
"id" => [
"type" => "long",
],
"last_name" => [
"type" => "string",
"analyzer" => "standard",
],
"location" => [
"type" => "geo_point",
"fielddata" => [
"format" => "compressed",
"precision" => "1km",
],
],
"quirky_fact" => [
"type" => "string",
"analyzer" => "standard",
],
"updated_at" => [
"type" => "string",
],
"user_id" => [
"type" => "long",
],
],
],
],
],
]
查询
curl -XGET localhost:9200/crushlings/user_profiles/_search?pretty -d
'{
"query": {
"function_score": {
"functions": [
{
"gauss": {
"dob": {
"origin": "2015-08-08",
"scale": "6y",
"offset": "24y",
"decay": 0.33
}
}
}
],
"query": {
"bool": {
"must": {
"term": {
"gender": "0"
}
},
"must_not": {
"term": {
"gender": "0"
}
}
}
}
}
}
}'
获得以下错误
nested: ElasticsearchParseException[Failed to parse [6y]]; nested: NumberFormatException[For input string: \"6y\"]; }]", "status" : 400
索引文件
App\UserProfile {#1418
id: 1,
first_name: "First_1",
last_name: "Last_1",
gender: 1,
dob: "1996-12-08",
about_me: "Beatae harum.",
quirky_fact: "Non.",
location: "21.85646, 75.431322",
user_id: 1,
flagged: 0,
created_at: "2015-08-08 14:48:16",
updated_at: "2015-08-08 14:48:16",
},