【发布时间】:2016-06-06 02:44:56
【问题描述】:
我在使用通配符搜索某些字母组合时遇到性能问题,我不确定我还需要做些什么来改进它。我所有的文档都遵循如下所示的信封模式。
<pdbe:person-envelope>
<person xmlns="http://schemas.abbvienet.com/people-db/model">
<account>
<domain/>
<username/>
</account>
<upi/>
<title/>
<firstName>
<preferred/>
<given/>
</firstName>
<middleName/>
<lastName>
<preferred/>
<given/>
</lastName>
</person>
<pdbe:raw/>
</pdbe:person-envelope>
我定义了一个名为 name 的字段,其中包括 firstName 和 lastName 路径:
{
"field-name": "name",
"field-path": [
{
"path": "/pdbe:person-envelope/pdbm:person/pdbm:firstName",
"weight": 1
},
{
"path": "/pdbe:person-envelope/pdbm:person/pdbm:lastName",
"weight": 1
}
],
"trailing-wildcard-searches": true,
"trailing-wildcard-word-positions": true,
"three-character-searches": true
}
当我使用 search:search 进行一些查询时,有些返回速度很快,而另一些返回速度较慢。这是过滤后的查询。
search:search("name:ha*",
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="name">
<word>
<field name="name"/>
</word>
</constraint>
<return-plan>true</return-plan>
</options>
)
我可以从查询计划中看到,它将过滤数据库中的所有 136547 个片段。但是这个查询很快。
<search:query-resolution-time>PT0.013205S</search:query-resolution-time>
<search:snippet-resolution-time>PT0.008933S</search:snippet-resolution-time>
<search:total-time>PT0.036542S</search:total-time>
但是,搜索 name:tj* 需要很长时间,并且还会过滤掉所有 136547 个片段。
<search:query-resolution-time>PT6.168373S</search:query-resolution-time>
<search:snippet-resolution-time>PT0.004935S</search:snippet-resolution-time>
<search:total-time>PT12.327275S</search:total-time>
我在两者上都有相同的索引。当我专门通过字段约束进行搜索时,是否应该启用其他索引?一般来说,我在数据库本身上启用了这些其他索引。
"collection-lexicon": true,
"triple-index": true,
"word-searches": true,
"word-positions": true
我尝试进行未过滤的查询,但这并没有帮助,因为我在整个文档中找到了一堆匹配项,而不是我想要的字段。我什至尝试将根片段设置为我的 person 元素,但这似乎没有帮助。
"fragment-root": [
{
"namespace-uri": "http://schemas.abbvienet.com/people-db/model",
"localname": "person"
}
]
感谢您的任何想法。
【问题讨论】:
标签: search wildcard marklogic marklogic-8