EWS API搜索过滤器不会返回所有信息 [英] EWS API Search Filter does not return all information

查看:84
本文介绍了EWS API搜索过滤器不会返回所有信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况: 我检查了一个邮箱,带有一些相关信息的电子邮件被发送到该邮箱,以从中获取信息.

I have the following scenario: I check a mailbox to which emails with some relevant information are sent to to get the information from it.

我使用很多搜索过滤器来查找特定的电子邮件并获取正确的电子邮件:

I use a lot of search filters to find the specific email and to get the correct one:

var collection = new SearchFilter.SearchFilterCollection(LogicalOperator.And);
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "text1", ContainmentMode.Substring, ComparisonMode.Exact));
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "text2", ContainmentMode.Substring, ComparisonMode.Exact));
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "text3", ContainmentMode.Substring, ComparisonMode.Exact));
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "text4", ContainmentMode.Substring, ComparisonMode.Exact));
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "text5", ContainmentMode.Substring, ComparisonMode.Exact));
collection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "longer string 1", ContainmentMode.Prefixed, ComparisonMode.IgnoreCase));

但是现在我有一个问题,就是我并不总是能找到正确的电子邮件.我进行了非常简单的测试:我向正在轮询的邮箱发送了一条消息,该消息看起来完全等同于另一条消息.在这两种情况下,都包括上面的所有信息. 但是,然后,当我更改SearchFilter上的某些内容或任何其他内容后,突然看到了正确的结果,即最新消息.

But now I have the problem that I do not always find the correct email messages. I tested that very simple: I sent a message to that mailbox I am polling that looks completely equal to another message. In both cases all information from above are included. But then, after I changed something on my SearchFilters or anything I suddenly see the correct result, the latest message.

我不知道是什么原因引起的,因为它太普通了.

I have no idea what could cause the problem, because it's so ungeneric.

推荐答案

您的查询看起来非常复杂,并且就服务器性能而言非常昂贵.例如,您的搜索过滤器将需要转换为MAPI限制,然后应用于服务器

Your query looks very complex and would be very costly in terms of Server performance. Eg your Search Filter will need to be converted to a MAPI restriction and then applied to the server https://technet.microsoft.com/en-us/library/cc535025(v=exchg.80).aspx the way you keep applying multiple sub-strings I doubt will be reliable unless the data-set your querying is quite small. Because Restrictions are cached by the server the behaviour your seeing is probably just the time the backend is taking to build or refresh the restriction. (eg if your query the same thing again and get a really quick response that would indicate a cached result) or its just the process of forcing the new one being created which is finding the newest items first.

通过简化搜索过滤器并在客户端处理更多项目(可以使用多种方法处理文本)方面,您会得到更好的服务.或查看使用AQS(或2013年使用KQL)

You would be much better served by either making your search filter much simpler and dealing with more items at the client side where the text can processed by many different methods. Or look at using AQS (or KQL in 2013) https://msdn.microsoft.com/en-us/library/office/dn579420(v=exchg.150).aspx then you doing Keyword queries of the Content indexes (which is what the Search process is optimised for). While you might get more false positives this way it should be a lot quicker and more reliable and filtering the false positives at the client is much easier.

如果要使用Rest Cache,则需要使用Raw Soap,因为我不相信Managed API将支持它.它是QueryString元素的一个属性,例如

If you want to use Rest Cache you need to use Raw Soap as i don't believe the Managed API will support it. Its an Attribute of the QueryString Element eg

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                   xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
                   xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
                   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <t:RequestServerVersion Version="Exchange2010" />
      </soap:Header>
      <soap:Body>
        <m:FindItem Traversal="Shallow">
          <m:ItemShape>
            <t:BaseShape>IdOnly</t:BaseShape>
            <t:AdditionalProperties>
              <t:FieldURI FieldURI="item:Subject" />
            </t:AdditionalProperties>
          </m:ItemShape>
          <m:IndexedPageItemView MaxEntriesReturned="1" Offset="0" BasePoint="Beginning" />
          <m:ParentFolderIds>
            <t:DistinguishedFolderId Id="inbox" />
          </m:ParentFolderIds>
          <m:QueryString ResetCache="true">subject:Autodiscover</m:QueryString>
        </m:FindItem>
      </soap:Body>
    </soap:Envelope>

这篇关于EWS API搜索过滤器不会返回所有信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆