locked
IndexerOption in QueryOptions class is not working

    Question

  • Hello,

    I am searching the Pictures folder with the "UserSearchFilter" as "hello" and "IndexerOption" as UseIndexerWhenAvailable. The Pictures folder contains 100 files. Among them 10 files have the file names with "hello" combination. When i execute "GetFilesAsync", the result returned all the 100 files which is not correct. The correct result should contain ONLY 10 files.

    If i change the "IndexerOption" to DoNotUseIndexer", i am getting the correct result which is 10 files in this case.

    I have the following code:

    try
    {
      QueryOptions queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".jpg", ".png" });
    
      queryOptions.UserSearchFilter = "hello";
      queryOptions.FolderDepth = FolderDepth.Deep;
      queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;// Issue occurs here. DoNotUseIndexer works fine
      StorageFolder folder = Windows.Storage.KnownFolders.PicturesLibrary;
      StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);
                   
      IReadOnlyList<StorageFile> List = await queryResult.GetFilesAsync();
    }
    catch(Exception)
    {
    }

    Hope you can understand my issue and resolve my problem.

    Thanks,

    Balaji

    Wednesday, July 30, 2014 6:45 AM

All replies

  • Hi Balaji,

    I can understand your question, but I can't reproduce the issue. UseIndexerWhenAvailable gave me a correct result.

    I have 12 files in my Picture library among them I got only 4 Images contains "12" in the name, I set my UserSearchFilter as "12" and I got a correct amount.

    By the way Advanced Query Syntax (AQS) does not only filter for name but also filter for other properties for instance height, width, tag and etc, you may need to see if your files contains "hello" in somewhere.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, July 31, 2014 7:44 AM
    Moderator
  • Hi James,

    Thanks for the reply.

    I am still able to reproduce this issue. I am not using Advanced Query Syntex(AQS) in my code.

    This code was working fine before installing Windows 8.1 SP1 Update. But after installing Windows 8.1 SP1 Updates, i was getting this issue.

    Note: If i use IndexerOption as DoNotUseIndexer, then the results are correct. If i use IndexerOption other than DoNotUseIndexer, then the results are wrong. GetFilesAsync() returns all the files present in the Pictures folder.

    Thanks,

    Balaji

    Friday, August 01, 2014 5:53 AM
  • Hi Balaji,

    So you believe that the problem is Windows 8.1 SP1 update? Might be correct, and I will send this to our seniors to see if this is the root cause. Thanks for your information.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 04, 2014 9:44 AM
    Moderator
  • Hi James,

    Please update the status. We are currently in the final stage of product release.

    Based on your updates we will decide whether to use the Indexer option or remove it.

    Thanks,

    Balaji

    Tuesday, August 05, 2014 5:24 AM
  • Hi Balaji,

    It sounds like a strange issue at first glance, I am not very sure whether the issue is related to Win 8.1 SP1 update, however I have tried several times to reproduce the issue on my side, finally I got a solid reason for explaining this encountered issue.

    Let's start at the definition of IndexerOption enumeration:

    • UseIndexerWhenAvailable means: Use the system index for content that has been indexed and use the file system directly for content that has not been indexed.
    • DoNotUseIndexer means: Access the file system directly; don't use the system index.

    Then I use blow code snippet to reproduce the issue:

     void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                var mytask = Search();
                mytask.GetAwaiter().OnCompleted(() => {
                    IReadOnlyList<StorageFile> List = mytask.Result;
                    int numberCount = List.Count;
                });
            }
            public async Task<IReadOnlyList<StorageFile>> Search()
            {
                IReadOnlyList<StorageFile> List = null;
                try
                {
                    QueryOptions queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".jpg", ".png" });
    
                    queryOptions.UserSearchFilter = "Hello";
                    queryOptions.FolderDepth = FolderDepth.Deep;
                    queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;
                    StorageFolder folder = Windows.Storage.KnownFolders.PicturesLibrary;
                    StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);
    
                    List = await queryResult.GetFilesAsync();
                }
                catch (Exception)
                {
                }
                return List;
            }
     

    If we leverage 'IndexerOption.UseIndexerWhenAvailable' to search the files, it would check the properties of file as well, I mean, if you have any properties of file contains 'Hello', the search result would contains that file, e.g. I have below files list in Picture Library:

    The expected search result would only contain 3 files if I search via 'Hello', however since the Author info of image '123.jpg' contains 'Hello':

    The search result would loop it in due to we use IndexerOption.UseIndexerWhenAvailable.

    Thus, I'd like to suggest you to check whether your file's properties contain your query keywords, please check and see whether the code works as expected if you remove those info from your files' properties.

    Should you have any concern, please let me know.

    Thank you.

    Best Regards,

    Ming Xu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 13, 2014 2:58 PM
    Moderator
  • Hi Ming Xu,

    I understood your post. 

    I am still getting the same result. I have even checked the files properties. Nowhere the search keyword is present in the files properties. The Authors and other properties are empty.

    If required i can share my sample files for reproducing this issue.

    Regards,

    Balaji

    Thursday, August 14, 2014 7:33 AM
  • Hi there, 

    Can you share a reproduction sample also together with test files? 

    Regards,

    Jenny 

    Thursday, August 14, 2014 7:41 AM
  • Hi Jenny,

    I have uploaded the sample windows store app and test files in the below OneDrive location.

    Shared link is https://skydrive.live.com/redir?resid=7480C5A54AA944D!238

    This issue will reproduce when you search with "sharp" keyword.

    Regards,

    Balaji

    Tuesday, August 19, 2014 11:14 AM
  • Hi Jenny,

    Please update the status.

    Thanks,

    Balaji

    Friday, September 05, 2014 6:43 AM
  • I only find a windows store app package in your link, unfortunately please understand that debugging the package is effort-consuming which is out of a forum scope.

    Regards,

    Jenny

    Tuesday, September 09, 2014 8:17 AM