首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bleve命令行示例

Bleve命令行示例
EN

Stack Overflow用户
提问于 2019-04-19 18:06:41
回答 1查看 286关注 0票数 0

是否有详细说明Bleve CLI使用的示例?

在网站上记录了函数和参数,但在实践中,很难知道方法签名和必填字段是什么。

经过一些谷歌搜索,我发现了以下Github的要点:https://gist.github.com/mschoch/5afa9ce2ae087dd240bf

但它似乎有点过时了。即使在复制完之后,我仍然会遇到一些莫名其妙的错误信息(比如Error: error creating index: cannot create new index, path already exists)。

任何信息都会有帮助。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-04-20 03:01:30

对我很管用

代码语言:javascript
复制
$ go version
go version go1.11.6 linux/amd64
$ go get -u github.com/blevesearch/bleve/...
$ sh test-bleve-search.sh 
+ set -e
+ cat
+ rm -fr test.bleve
+ bleve create ./test.bleve --mapping ./mapping.json
+ cat
+ bleve index test.bleve test.json
Indexing: test
+ bleve query test.bleve location.state:IN
1 matches, showing 1 through 1, took 173.341µs
    1. test (0.306853)
    location.state
        IN

使用固定的脚本

代码语言:javascript
复制
#!/bin/sh

set -x
set -e

# create a custom mapping
cat > mapping.json << MAPPING
{
  "types": {
    "_default": {
      "properties": {
        "location": {
          "properties": {
            "state": {
              "fields": [
                {
                  "name": "state",
                  "type": "text",
                  "analyzer": "keyword",
                  "store": true,
                  "index": true,
                  "include_term_vectors": true,
                  "include_in_all": true
                }
              ]
            }
          }
        }
      }
    }
  }
}
MAPPING

rm -fr test.bleve

# create index
bleve create ./test.bleve --mapping ./mapping.json

# create JSON file to index
cat > test.json <<DELIM
{
    "name": "test",
    "location": {
        "address1": "777 TEST ROAD",
        "address2": "",
        "city": "HIGHLAND HEIGHTS",
        "state": "IN",
        "zip": "777777",
        "countryCode": "",
        "latitude": 41.549536,
        "longitude": -81.454717
    }
}
DELIM

# index test file
bleve index test.bleve test.json

# query for the file we indexed
bleve query test.bleve location.state:IN
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55760155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档