2016-02-27 37 views
0

目前我正在爲我的項目進行彈性搜索。我需要顯示我的記錄(最新的第一個)。我正在使用排序技術。 "sort" => array(array('created_date' => 'desc')),獲取最新的彈性搜索記錄

和我的映射一切的字符串。 `「產品」:{

"properties":{ 
    "add_by":{ 
     "type":"string" 
    }, 
    "categories":{ 
     "properties":{ 
      "category_name":{ 
       "type":"string" 
      }, 
      "id":{ 
       "type":"string" 
      } 
     } 
    }, 
    "company_logo":{ 
     "type":"string" 
    }, 
    "company_name":{ 
     "type":"string" 
    }, 
    "created_date":{ 
     "type":"string" 
    }, 
    "id":{ 
     "type":"string" 
    }, 
    "industries":{ 
     "properties":{ 
      "id":{ 
       "type":"string" 
      }, 
      "industry_name":{ 
       "type":"string" 
      } 
     } 
    }, 
    "location":{ 
     "type":"string" 
    }, 
    "location_latitude":{ 
     "type":"string" 
    }, 
    "location_longitude":{ 
     "type":"string" 
    }, 
    "num_of_employees":{ 
     "type":"string" 
    }, 
    "practice_areas":{ 
     "properties":{ 
      "id":{ 
       "type":"string" 
      }, 
      "practice_area_image":{ 
       "type":"string" 
      }, 
      "practice_area_name":{ 
       "type":"string" 
      } 
     } 
    }, 
    "product_description":{ 
     "type":"string" 
    }, 
    "product_image":{ 
     "type":"string" 
    }, 
    "product_name":{ 
     "type":"string" 
    }, 
    "product_rating":{ 
     "type":"string" 
    }, 
    "status":{ 
     "type":"string" 
    }, 
    "updated_date":{ 
     "type":"string" 
    }, 
    "user_id":{ 
     "type":"string" 
    }, 
    "user_sub_type":{ 
     "type":"string" 
    }, 
    "user_type":{ 
     "type":"string" 
    } 
} 

}` 我想我可能我更新我的映射像ID和CREATED_DATE(兩者都更新到整數和時間戳)。請幫助我如何更新我的類型(產品)的映射。先謝謝了。

回答

1
  • - >您正在運行哪個elasticsearch版本?

  • - >最新版本不支持更新映射類型。

  • - >如果你想改變映射,你需要用新的映射創建新的索引,並從舊索引的數據複製到新的索引

  • - >另一個進程:插入新的領域有新的映射和使用copy_to映射。

    例如:

      'id' => [ 
            'type' => 'string', 
    
            'copy_to' => 'combined' 
           ], 
           'newid' => [ 
            'type' => 'integer', 
    
           ], 
    
          'created_at' => [ 
            'type' => 'string', 
    
            'copy_to' => 'date' 
           ], 
          'date' => [ 
            'type' => 'date', 
            'format' => 'yyyy-MM-dd HH:mm:ss', 
    
           ], 
    
+0

目前我使用彈性2.0版本。 –

+0

我不支持版本2.0更新映射類型。 [鏈接](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) –

+0

版本2.0不支持在提供的鏈接中更新mapping.read更新maaping。[這裏檢查](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) –