首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搜索:搜索和搜索:代码段匹配路径

搜索:搜索和搜索:代码段匹配路径
EN

Stack Overflow用户
提问于 2016-05-02 10:34:44
回答 1查看 59关注 0票数 0

我的记录看起来像这样:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<person>
   <account>
      <domain>ABBVIENET</domain>
      <username>TANGTJ</username>
      <status>ENABLED</status>
   </account>
   <company>AbbVie Inc. (Parent)</company>
   <displayName>Tj Tang</displayName>
   <upi>10025613</upi>
   <firstName>
      <preferred>TJ</preferred>
      <given>Tze-John</given>
   </firstName>
   <middleName/>
   <lastName>
      <preferred>Tang</preferred>
      <given>Tang</given>
   </lastName>
   <secondaryLastName/>
   <address>
      <streetAddress>1 N Waukegan Road</streetAddress>
      <buildingCode>AP52</buildingCode>
      <city>North Chicago</city>
      <state>Illinois</state>
      <country>
         <code>US</code>
         <name>United States</name>
      </country>
   </address>
   <emailAddress>tze-john.tang@abbvie.com</emailAddress>
   <title>Principal Research Scientist</title>
   <managerUpi>10009618</managerUpi>
</person>

当我使用以下命令搜索时:

代码语言:javascript
复制
search:search("Tang TJ AbbVie")

我得到了:

代码语言:javascript
复制
<search:snippet>
  <search:match path="fn:doc(&quot;/person/10025613.xml&quot;)/person/company"><search:highlight>AbbVie</search:highlight> Inc. (Parent)
  </search:match>
  <search:match path="fn:doc(&quot;/person/10025613.xml&quot;)/person/displayName">Tj <search:highlight>Tang</search:highlight></search:match>
    <search:match path="fn:doc(&quot;/person/10025613.xml&quot;)/person/firstName">
      <search:highlight>TJ</search:highlight>
  </search:match>
  <search:match path="fn:doc(&quot;/person/10025613.xml&quot;)/person/lastName">
      <search:highlight>Tang</search:highlight>
  </search:match>
</search:snippet>

它向我显示了匹配的元素,即match在/person/firstName/preferred中,它显示/person/firstName。

如果我搜索UPI值:

代码语言:javascript
复制
search:search("10025613")

我得到了:

代码语言:javascript
复制
<search:snippet>
    <search:match path="fn:doc(&quot;/person/10025613.xml&quot;)/person">
      <search:highlight>10025613</search:highlight>
    </search:match>
</search:snippet>

在这种情况下,我甚至没有获得上下文的较低级别的元素。如何在代码片段上确定元素路径?我尝试为UPI值添加一个元素范围索引,但仍然得到相同的结果。

EN

回答 1

Stack Overflow用户

发布于 2016-05-05 07:43:25

搜索API处理匹配是嵌入式内联元素的全部内容的情况,如下所示:

代码语言:javascript
复制
<p>Before the <b>match</b> and after</p>

在这种情况下,搜索API将使用inline元素前后的文本作为代码片段(而不是不为匹配提供代码片段)。

为了正确处理这种情况,搜索API必须将其与匹配在结构中的叶元素的整个内容上的情况区分开来。

上面的upi元素是叶元素情况的一个示例。

在8.0-5之前的版本中,搜索API可能有一个错误,将叶子元素的大小写与嵌入式内联大小写混淆。

希望这能澄清,

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36974255

复制
相关文章

相似问题

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