2014-01-23 38 views
5

Elasticsearch如何處理索引?我有一個名爲Coordinates的字段,它在名爲users的集合中有子字段latlng。我想在這個集合中搜索,但是通過索引座標字段。在我的MongoDB配置中,coordinate字段已經是2D索引。我如何嘗試告訴ElasticSearch搜索該字段的索引?它是否知道座標是一個索引?或者我應該通過這個腳本來告訴它?elasticsearch如何工作?

curl -XPUT "localhost:9200/_river/artist/_meta" -d' 
{ 
    "type": "mongodb", 
    "mongodb": { 
     "db": "mydb", 
     "collection": "users" 
    }, 
    "index": { 
     "name": "coordin", 
     "type": "coordinates" 
    } 
}' 
+1

我做了一些編輯,但它仍然很不清楚,你需要什麼。我建議閱讀一些關於ElasticSearch如何工作的文章,觀看一些教程等。這裏的一些文章可能會有所幫助 - http://blog.smeef.co.uk/category/elastic-search/ – Nate

+1

還有一些非常好的文章位於這裏 - https ://www.found.no/foundation/ – Nate

回答

0

我假設這裏的「索引」是指在MongoDB和SQL服務器上的意思。在elasticsearch上下文中,它是一個集合typesdocuments,更像是一個數據庫集合tablesrows。默認情況下,elasticsearch中的所有字段都存儲在一個Lucene數據結構中,從中可以高效地查詢它。

Elasticsearch支持索引的地理空間數據,文檔可以從here找到。

0

Elasticsearch的工作原理是你的索引配置,假設你已經配置好了一切,你準備好接受你需要編輯文件中/etc/elasticsearch/templates/ 下面的示例所示找到一些文件是log4net,我添加了地理空間的配置,我發現here

{ 
    "log4net": { 
    "template": "log4net*", 
    "mappings": { 
     "fluentd": { 
     "_ttl": { 
      "enabled": true, 
      "default": "62d" 
     }, 
     "properties": { 
      "hostname": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "level": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "enviroment": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "site": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "username": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "logger": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "thread": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "systemname": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "message": { 
      "type": "string", 
      "index": "not_analyzed" 
      }, 
      "location": { 
      "type": "geo_point", 
      "fielddata": { 
       "format": "compressed", 
       "precision": "1cm" 
      } 
      } 
     } 
     } 
    } 
    } 
}