You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>例如:对于上述的文档,doc[“skus”] 是无效的:<br><figureclass="highlight haxe"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br></pre></td><tdclass="code"><pre><spanclass="line"><spanclass="string">"script"</span>: <spanclass="type"></span>"<spanclass="keyword">for</span>(sku <spanclass="keyword">in</span> doc[<spanclass="string">'skus'</span>]){<spanclass="keyword">if</span>(sku.price><spanclass="number">5</span>){<spanclass="keyword">return</span><spanclass="literal">true</span>;}};<spanclass="keyword">return</span><spanclass="literal">false</span>;<spanclass="string">" //No field found for [skus] in mapping!</span></span><br></pre></td></tr></table></figure></p>
<p>doc[“name”] 无效是因为 name 为 analyzed 的字段:<br><figureclass="highlight 1c"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br></pre></td><tdclass="code"><pre><spanclass="line"><spanclass="string">"script"</span>: <spanclass="string">"doc['name'].value.length()>=10"</span><spanclass="comment">//not found</span></span><br></pre></td></tr></table></figure></p>
416
-
<p>虽然访问 doc[‘name’]无效,但是并不报错,其实对于这种分词的字段,访问 doc[‘name’] 其实访问的是分词过后的 token,所以不会报 no field found for [name] in mapping 错误。<br>doc[‘name2’]有效,因为 name2 字段 是 not_analyzed 的(可以理解为不分词):<br><figureclass="highlight 1c"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br></pre></td><tdclass="code"><pre><spanclass="line"><spanclass="string">"script"</span>: <spanclass="string">"doc['name2'].value.length()>=10"</span><spanclass="comment">//found</span></span><br></pre></td></tr></table></figure></p>
<p>doc[“name”] 无效是因为 name 为 analyzed 的字段:<br><figureclass="highlight php"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br></pre></td><tdclass="code"><pre><spanclass="line"><spanclass="string">"script"</span>: <spanclass="string">"doc['name'].value.length()>=10"</span><spanclass="comment">//not found</span></span><br></pre></td></tr></table></figure></p>
416
+
<p>虽然访问 doc[‘name’]无效,但是并不报错,其实对于这种分词的字段,访问 doc[‘name’] 其实访问的是分词过后的 token,所以不会报 no field found for [name] in mapping 错误。<br>doc[‘name2’]有效,因为 name2 字段 是 not_analyzed 的(可以理解为不分词):<br><figureclass="highlight php"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br></pre></td><tdclass="code"><pre><spanclass="line"><spanclass="string">"script"</span>: <spanclass="string">"doc['name2'].value.length()>=10"</span><spanclass="comment">//found</span></span><br></pre></td></tr></table></figure></p>
0 commit comments