In my UWP App I am creating files that should be indexed by the Windows-index so they can be found later using full-text search.
public async Task TestFullTextSearch()
{
StorageFolder folder = ApplicationData.Current.LocalCacheFolder;
CreateFile(folder.Path + Path.DirectorySeparatorChar + "myDocument.txt", "Some text 123");
await Task.Delay(5000); // to ensure that the file is already index before querying
int numberOfResults = await SearchForResults(folder, "*");
// numberOfResults is 1 in Windows 10, 1709 and 0 in 1803
}
public void CreateFile(string path, string text)
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(text);
}
}
private async Task<int> SearchForResults(StorageFolder folder, string searchString)
{
QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderBySearchRank, new List<string>() { "*" });
queryOptions.UserSearchFilter = searchString;
StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);
IReadOnlyList<StorageFile> files = await queryResult.GetFilesAsync();
return files.Count;
}
In the example above, when executing the code under Windows 10, 1709, numberOfResults
is 1. When executing the same code under Windows 10, 1803, numberOfResults
is 0.
In both cases, the location is added to the Windows-index (added via "Indexing Options").
I checked the permissions and they appear to be exactly the same. I also tried to create a file manually in the respective folder and use the windows search of the Windows Explorer, it shows 0 results (under 1803, under 1709 the results are shown as expected). In a few cases, the created file ended up in the query and was searchable, I have no clue why.
I tried this under 3 different Windows 10, 1803 machines and the results are exactly the same (and on several 1709 machines, here it works fine).