1

I added an advance search web part inside my team site inside sharepoint enterprise server 2013, as follow:-

enter image description here

but i am unable to understand how the contain actually works. for example i have these 3 items with the following titles:-

  1. Project A
  2. Project B
  3. Project C

now i tried to search the items' title using the Contain:-

  • "project" --> will get all the three.
  • "A" ---> will get only "Project A"
  • "ject" --> will not get any !! altohugh the 3 title contains the substring "ject"
  • "*ject*" ---> will return nothing.

so now our users and also me as a sharepoint developer got confused .. we were expecting if we select to search "Title --> Contain --> ject" to get all result , but in reality we did not get any thing.

so can anyone adivce how i can modify my advance search web part to force the contain to do a sub-string search for the Title and other fields ?

here is the XML for the advance search web part:-

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <LangDefs>  </LangDefs>
  <Languages>      </Languages>
  <PropertyDefs>

    <PropertyDef Name="Title" DataType="text" DisplayName="Title"/>
    <PropertyDef Name="ProjectStatusOWSCHCS" DataType="text" DisplayName="Project Status"/>
    <PropertyDef Name="ProgrammeRevissionOWSTEXT" DataType="text" DisplayName="Programme or VersionRelease"/> 
    <PropertyDef Name="ProjectDepartmentOWSTEXT" DataType="text" DisplayName="Project Department"/>
    <PropertyDef Name="Author" DataType="text" DisplayName="Author"/>

  </PropertyDefs>
  <ResultTypes>
    <ResultType DisplayName="All Results" Name="default">
      <KeywordQuery>FileExtension="aspx" AND ContentTypeId="0x01030045D0C14FCBDF544096200156760C935B0086AB4ECA241FC34692055C76C1C9392B"</KeywordQuery>
      <PropertyRef Name="Title" />
      <PropertyRef Name="ProjectStatusOWSCHCS" />
      <PropertyRef Name="ProgrammeRevissionOWSTEXT" />
      <PropertyRef Name="ProjectDepartmentOWSTEXT" />
      <PropertyRef Name="Author" DataType="text" />
    </ResultType>

  </ResultTypes>
</root>
  • 1
    Wildcards don't work when they're used at the beginning of the search string so "*ject" will try to find that exact string "*ject" followed by anything (the wildcard still works at the end). – Arin Zandbergen Dec 2 '16 at 19:42
  • @ArinZandbergen so is there a way to force a pre-fix matching when users select the "contain" option inside my advance search web part? – john Gu Dec 2 '16 at 20:55
  • Not that I am aware. – Arin Zandbergen Dec 2 '16 at 22:04
2

(From MS official Documentation)

When you use words in a free-text KQL query, Search in SharePoint 2013 returns results based on exact matches of your words with the terms stored in the full-text index. You can use just a part of a word, from the beginning of the word, by using the wildcard operator (*) to enable prefix matching. In prefix matching, Search in SharePoint 2013 matches results with terms that contain the word followed by zero or more characters. For example, the following KQL queries return content items that contain the terms "federated" and "search":

  1. federated search
  2. federat* search
  3. search fed*

KQL queries don’t support suffix matching.

Source: MSDN

  • so you mean it is not possible to force the "contain" inside my advance search webpart to search for substrings ? second question if the answer is NO, then can i atleast allow the pre-fix matching when the user select the "contain" option? so if the user specify to search for example "Title-->Contain-->"fed"" to return "federated"?? – john Gu Dec 2 '16 at 21:00
  • 2
    It's default behavior to allow the trailing wildcards so yeah if you do a search for fed* it should return federated. – Arin Zandbergen Dec 2 '16 at 22:02
  • @ArinZandbergen ok i got your point.. so sharepoint search will not allow searching for substring this is by design.. but to make the contain more user-friendly inside my advacne search web part , can i modify the advance search web part to automatically add "" at the end of the search criteria if user select "contain"?? because it is somehow technical behavioure to inform end users that they need to add "" to do pre-fix match !! – john Gu Dec 2 '16 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.