Lucene有一个"更喜欢这个"的功能,可以找到类似的文件.我如何使用MarkLogic做到这一点?
我有一个奇怪的问题,我正在做cts:uri和cts:search ..而且我的cts:uris给了我7个结果,其中cts:搜索只给出了3个结果..
不知道我做错了什么,希望有人可以指出我做错了什么.我尝试了所有我认识的可能性:) ..遵循我正在运行的代码
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
let $q := '(Dermatolog*) AND ((context:KN)) AND ((gene:"STAT3") AND (indication:"Carcinoma")) AND ((uploadDate:"today")) AND (sort:date_desc)'
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:collection-query xmlns:cts="http://marklogic.com/cts">
<cts:uri>http://abc/xyz/type/envelope</cts:uri>
</cts:collection-query>
</additional-query>
<operator name="sort">
<state name="date_desc">
<sort-order type="xs:dateTime" direction="descending">
<field name="upload_date"/>
</sort-order>
</state>
<state name="date_asc">
<sort-order type="xs:dateTime" direction="ascending">
<field name="upload_date"/>
</sort-order>
</state>
</operator>
<constraint name="context">
<range type="xs:string" facet="true">
<element name="context" ns="http://abc/xyz/metadata"/>
<facet-option>frequency-order</facet-option>
<facet-option>descending</facet-option>
</range>
</constraint>
<constraint name="type"> …Run Code Online (Sandbox Code Playgroud) 如何导入多个xsd文件以在xQuery Marklogic中进行验证。
import schema default element namespace "" at "/schema/a.xsd", "/schema/b.xsd";
Run Code Online (Sandbox Code Playgroud)
如果有可能通过Marklogic进行验证
只是数据.状态选项卡中的数据库大小应为0 MB.
是否有任何API可以完成工作,如果我尝试使用unix命令清除所有目录,该怎么办?推荐吗?
通常当我在XSLT中工作时,我创建一个主要由导入组成的主文件.我保持每个导入文件都很小,以便我更容易维护.
我正在尝试在XQuery(在MarkLogic中)做同样的事情,但我无法按照我希望的方式工作.
这是我希望能够做到的:
main.xqy:
xquery version "1.0-ml";
module namespace summit = "http://example.com/summit";
import module "http://example.com/summit" at "/ext/variables.xqy";
import module "http://example.com/summit" at "/ext/utils.xqy";
Run Code Online (Sandbox Code Playgroud)
variables.xqy:
xquery version "1.0-ml";
module namespace summit = "http://example.com/summit";
declare variable $BASEURL as xs:string := "https://example.com/v1";
Run Code Online (Sandbox Code Playgroud)
utils.xqy:
xquery version "1.0-ml";
module namespace summit = "http://example.com/summit";
declare function summit:baseUrl() {
let $url := $BASEURL
return $url
};
Run Code Online (Sandbox Code Playgroud)
然后使用以下代码在查询控制台中调用它:
xquery version "1.0-ml";
import module namespace summit = "http://example.com/summit" at "/ext/main.xqy";
summit:baseUrl()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[1.0-ml] XDMP-UNDVAR: (err:XPST0008) Undefined variable $BASEURL
Stack Trace …Run Code Online (Sandbox Code Playgroud) 给出以下xml文件,知道结构和内容可以更改:
<something>
<parent>
<child>Bird is the word 1.</child>
<child>Curd is the word 2.</child>
<child>Nerd is the word 3.</child>
</parent>
<parent>
<child>Bird is the word 4.</child>
<child>Word is the word 5.</child>
<child>Bird is the word 6.</child>
</parent>
</something>
Run Code Online (Sandbox Code Playgroud)
我想用一种方法来使用xquery(甚至xslt)来替换所提供的字符串的所有实例.例如,将"Bird"替换为"Dog".因此结果将是:
<something>
<parent>
<child>Dog is the word 1.</child>
<child>Curd is the word 2.</child>
<child>Nerd is the word 3.</child>
</parent>
<parent>
<child>Dog is the word 4.</child>
<child>Word is the word 5.</child>
<child>Dog is the word 6.</child>
</parent>
</something>
Run Code Online (Sandbox Code Playgroud)
我不知道这是否可能.我所做的每一次尝试都消除了标签.我甚至尝试了这个例子(http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx),但是文本不是整个文档.
请帮忙!
UPDATE
我尝试使用xslt …
我正在使用Ubuntu机器.我正在使用curl命令进行POST调用,并以字符串格式将xquery代码作为--data 发送.作为回应我得到以下错误:
xdmp:database()HTTP/1.1 500 REST-UNSUPPORTEDPARAM: (rest:UNSUPPORTEDPARAM) Endpoint does not support query parameter: xdmp:database()
Run Code Online (Sandbox Code Playgroud)
下面是完整的curl命令
curl -v --digest -u username --request POST "http://host:port/qconsole/endpoints/evaler.xqy?dbid=someid&querytype=xquery&action=eval" --data "xdmp:database()"
Run Code Online (Sandbox Code Playgroud)
在上面的命令基本上我试图在目标机器上运行xquery代码(主机:端口/端点/ evaler.xqy)
这是传递xquery代码的正确方法吗?
更新:
我正在使用ML 7
传递头文件后,我能够运行XQuery代码,但又面临一个问题.
当我传递"xdmp:database()"作为数据它工作正常(参见下面的命令),在响应中我得到数据库ID.
curl -v --digest -uusername --data "xdmp:database()" --header "Content-type:text/x-www-form-urlencoded" --header "Accept: multipart/mixed; boundary=BOUNDARY" --request POST "http://host:port/qconsole/endpoints/evaler.xqy?dbid=dbid&querytype=xquery&action=eval"
Run Code Online (Sandbox Code Playgroud)
当我尝试传递"let $ x:= 10 return $ x"作为数据时(如下面的命令所示)我得到了
x:未定义的变量
甚至不要求密码!!
curl -v --digest -u username --data "let $x := 10 return $x" --header "Content-type:text/x-www-form-urlencoded" --header "Accept: multipart/mixed; boundary=BOUNDARY" --request POST …Run Code Online (Sandbox Code Playgroud) 我想从文档的数组元素部分搜索具有键值的元素.让我说我有json看起来像 -
{
"name":"abc",
"lastName":"xyz",
"description":"aaaaa aaaa",
"dob":11-10-1988,
"workInformation":[
{
"address":"kolkata",
"workFor":"vvv Pvt Ltd"
},
{
"address":"bangalore",
"workFor":"www Pvt Ltd"
}
]
}
Run Code Online (Sandbox Code Playgroud)
假设我想在数组属性workInformation中使用java api搜索下面提到的键和值 -
key - workFor,value - vvv私人有限公司
请让我知道,怎么做.
谢谢阅读.
我正在使用MarkLogic 9开发基于Web的搜索应用程序.我有一个查询构建接口,允许用户将字符串输入到与db中文档的特定JSON属性相对应的文本框中.这个想法是用户可以输入搜索条件,就像cts.parse(我使用服务器端javascript,而不是XQuery)所期望的那样,因此他们的搜索可能是任意复杂的,我不必处理自己解析查询.然而,经过一些测试,我发现了一个关于在布尔逻辑中使用括号的奇怪现象.也就是说,当你在括号中添加像cat和(dog OR bird)这样的语句时,cts.parse会将OR误认为是搜索词.
我将从我的网站提供一个实际的例子:
我构造了一个绑定对象来将查询绑定到我的文档的元素,
var qOpts = ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded"];
var bindings = {
main: function(operator, values, options){
return(
cts.orQuery([
cts.jsonPropertyWordQuery('title',values,qOpts),
cts.jsonPropertyWordQuery('abstract',values,qOpts),
cts.jsonPropertyWordQuery('meshterms',values,qOpts),
])
);
},
}Run Code Online (Sandbox Code Playgroud)
我的服务器端脚本调用,例如,
cts.parse('main:'+params.mainQuery,bind)Run Code Online (Sandbox Code Playgroud)
以下是输入的字符串和返回的查询的一些示例:
cts.orQuery([cts.jsonPropertyWordQuery("title", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.jsonPropertyWordQuery("abstract", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.jsonPropertyWordQuery("meshterms", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.wordQuery("heart", ["lang=en"], 1), cts.wordQuery("lung", ["lang=en"], 1)], [])Run Code Online (Sandbox Code Playgroud)
这个适当地为"大脑"术语的3个字段(标题,摘要,网格术语)生成jsonPropertyWordQuery,但是对于其他两个术语不能这样做,它只是生成一个cts.wordQuery().
cts.orQuery([cts.jsonPropertyWordQuery("title", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.jsonPropertyWordQuery("abstract", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.jsonPropertyWordQuery("meshterms", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.andQuery([cts.wordQuery("heart", ["lang=en"], 1), cts.wordQuery("lung", ["lang=en"], 1)], ["unordered"])], [])Run Code Online (Sandbox Code Playgroud)
cts.orQuery([cts.jsonPropertyWordQuery("title", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], 1), cts.jsonPropertyWordQuery("abstract", "brain", ["case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"], …Run Code Online (Sandbox Code Playgroud)我在MarkLogic中有以下XML存储,
<testDoc>
<test>
<test1>test1</test1>
<test2>test2</test2>
<test3>test3</test3>
</test>
</testDoc>
Run Code Online (Sandbox Code Playgroud)
我的要求是只获得子节点的xpath,如果我将测试(部分节点名称)传递给我的xquery然后我期待
/testDoc/test/test1
/testDoc/test/test2
/testDoc/test/test3
Run Code Online (Sandbox Code Playgroud)
但是我的xquery回来了,
/testDoc
/testDoc/test
/testDoc/test/test1
/testDoc/test/test2
/testDoc/test/test3
Run Code Online (Sandbox Code Playgroud)
我在qconsole上执行的XQuery是,
xquery version "1.0-ml";
let $xml := document { fn:doc("/test/testDoc")}
let $elem-name := "test"
let $elems := $xml//*[local-name()[contains(lower-case(.), lower-case($elem-name))]]
return $elems ! xdmp:path(.)
Run Code Online (Sandbox Code Playgroud)
请指导我达到我的要求.
marklogic ×10
marklogic-8 ×4
xquery ×4
curl ×1
javascript ×1
marklogic-9 ×1
ubuntu ×1
xml ×1
xslt ×1