小编use*_*340的帖子

elasticsearch:嵌套文档映射不起作用

我在弹性搜索中有以下json结构存储@ http://localhost:9200/mongoindex/documents/:

{
"text" : "OTesting1"
"otag" : "otag1"
"pages" : [{
      "text" : "1"
  "name" : "itag1"

    }, {
     "text" : "2"
     "name" : "itag2"
    }
]
}
Run Code Online (Sandbox Code Playgroud)

我已创建嵌套映射,如下所示,以启用嵌套搜索和嵌套过滤器:

http://localhost:9200/mongoindex/documents/_mapping [PUT]

{
  "documents": {
    "properties": {
      "pages": {
        "type": "nested"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

现在执行以下java代码:

Settings settings = ImmutableSettings.settingsBuilder()
                .put("cluster.name", "xyz").build();
        Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
        SearchResponse response = client.prepareSearch("mongoindex")
                .setTypes("documents")
                .setQuery(QueryBuilders.nestedQuery("documents", QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("pages.text", "1"))).scoreMode("avg"))
                .execute()
                .actionGet();
Run Code Online (Sandbox Code Playgroud)

但它给了我以下例外:

> Exception in thread "main"
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed
> …
Run Code Online (Sandbox Code Playgroud)

java elasticsearch

5
推荐指数
1
解决办法
3151
查看次数

Marklogic cts:或在循环中查询

我想cts:or-query在for循环中创建一个.我怎样才能做到这一点?

我的逻辑的一个例子:

let $query := for $tag in (1,2,3,4,5)
return myquery
Run Code Online (Sandbox Code Playgroud)

我想得到最终的查询,例如:

let $query := cts:or-query(
    (
    cts:element-query(xs:QName("ts:tag"),'1'),
    cts:element-query(xs:QName("ts:tag"),'2'),
    cts:element-query(xs:QName("ts:tag"),'3'),
    cts:element-query(xs:QName("ts:tag"),'4'),
    cts:element-query(xs:QName("ts:tag"),'5')
    )
)
Run Code Online (Sandbox Code Playgroud)

xquery marklogic

2
推荐指数
1
解决办法
744
查看次数

Marklogic:分数计算

我有以下xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<data>
<text>We are a doing nothing here you can say it time pass. what are you doing doing doing doing doing time?</text>
<text>We are a doing nothing here you can say it time pass. what are you doing doing doing doing doing time?</text>
</data>
Run Code Online (Sandbox Code Playgroud)

现在我执行以下查询:

let $hits :=
let $terms :=
let $node := xdmp:document-filter(doc("/content/C/Documents and Settings/vimleshm/Desktop/abc.xml"))
return 
(cts:distinctive-terms($node,
<options xmlns="cts:distinctive-terms"
xmlns:db="http://marklogic.com/xdmp/database">
<use-db-config>false</use-db-config>
<score>logtf</score>
<max-terms>100</max-terms>
<db:word-searches>true</db:word-searches>
<db:stemmed-searches>off</db:stemmed-searches>
<db:fast-phrase-searches>false</db:fast-phrase-searches>
<db:fast-element-word-searches>false</db:fast-element-word-searches>
<db:fast-element-phrase-searches>false</db:fast-element-phrase-searches>
</options>)//cts:term)
for $wq in $terms
where …
Run Code Online (Sandbox Code Playgroud)

marklogic

1
推荐指数
1
解决办法
302
查看次数

标签 统计

marklogic ×2

elasticsearch ×1

java ×1

xquery ×1