Search by partial File Name

Felix Read 30 Reputation points
2024-09-20T22:46:53.0133333+00:00

I have a question, I am trying to create a query that giving a text, I will find files whose name contain that text, or that their path contains that text.

I tried this querystring in sharepoint search

Here is an example If I enter the text IFL I generate this querystring and run in in sharepoint

(ItemPath:"IFL" OR ItemPath:IFL OR filename:"IFL" OR filename:IFL OR title:"IFL" OR title:IFL)

but for some reason I have files that I have named for example MW2-IFL-081524.xlsx that don’t appear, to find this file I have use MW2-IFL as text to find it and others that have similar name

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,717 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Kasper Larsen 0 Reputation points MVP
    2024-09-21T16:53:28.5433333+00:00

    The value "MW2-IFL-081524" is one value/word. Had the title been "MW2 IFL 081524" you would have been able to search for parts of the title, like FileName:"IFL" or FileName:"081524"

    The KQL operator : can only do a "begins with" when dealing with a single word, so FileName:"MW2-IFL*" will work, but FileName:"IFL" will not, neither would FileName:"IFL*" nor FileName:IFL

    0 comments No comments

  2. RaytheonXie_MSFT 35,711 Reputation points Microsoft Vendor
    2024-09-23T05:38:14.3066667+00:00

    Hi @Felix Read

    The KQL support prefix matching, you can use the wildcard operator (*). When you use the word is not the prefix word, you will need to specify individual words. It's how KQL query works in SharePoint:

    https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference

    When you use words in a free-text KQL query, Search in SharePoint 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 matches results with terms that contain the word followed by zero or more characters.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.