2016-02-05 139 views
0

我想多場elasticsearch多字段映射elasticsearch

  • 1字段映射 - 「在」應該包含所有的索引列,
  • 第二場 - 「原稿」應包含文本原樣。

例如:

"findings": { 
     "type": "multi_field", 
     "fields": { 
      "in": { 
      "type": "string" 
      }, 
      "orig": { 
      "type": "string", 
      "index":"not_analyzed" 
      } 
     } 

一旦我創建這個和查詢,這是它的外觀。

當index ='no'是否意味着該字段永遠不會被索引?

"findings": { 
        "type": "string", 
        "index": "no", 
        "fields": { 
        "in": { 
         "type": "string" 
        }, 
        "orig": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 

回答

0

"index" : "no"對不同類型有不同的含義。由於您的問題中的findings字段爲String,因此根據elasticsearch documentation,它具有以下含義。

不表示它根本不可搜索(作爲單個字段;它可能仍然包含在_all中)。設置爲no禁用include_in_all。

你不能直接搜索領域findings因爲它已得到index: no同時,您可以在使用findings.infindings.orig

你可以學習更多關於index財產here

2

Multi_fields已經從刪除搜索彈性搜索。

相反,任何核心字段類型(不包括對象和嵌套)現在都接受一個fields參數,如OP第二個示例中所示。

但是,當您在任何其他字段中指定fields時,它僅表示將內容複製到不同的字段並應用不同的分析器組來查詢相同的內容。

因此,當您指定index=no時,該字段不會被索引,因此不可搜索,但內部字段具有其自己的屬性。

您也可以使用copy_to到內容到其他領域複製,並指定有不同的分析,但再有就是這兩個領域之間的新領域作爲'findings.in''findings.orig'訪問是在multi_fields很明確沒有「明確的」關係

+0

謝謝..你是指OP的第二個例子嗎? – user1050619

+0

您在第一次映射中使用了「type」:「multi_field」,而在第二次映射中使用了「type」:「string」。第二個映射被稱爲第二個例子 – Rahul