SpotLight casesensitive and insensitive queries

  1. 8 weeks ago
    Edited 8 weeks ago

    Hello,

    Catalina and Xojo2019r1.1 and 2019r2.1

    according to Apple docs (MetadataAttrRef.html) the syntax for comparison is:

    kMDItemTextContent == "Paris" > Matches “Paris” but not “paris”.
    kMDItemTextContent ==[c] "Paris" > Matches “Paris” and “paris”.
    kMDItemTextContent ==[c] "*Paris*" > Matches “Paris”, “paris”, “I love Paris”, and “paris-france.jpg””.
    kMDItemTextContent == "Frédéric" > Matches “Frédéric” but not “Frederic”.
    kMDItemTextContent ==[d] "Frédéric" > Matches “Frédéric” and “Frederic” regardless of the word case.

    Yet, when I query "Carlo" using ==[c] or ==[d] I dont get any result, while when I use ==, then I get different results for Carlo or carlo.
    I found a dumb workaround adding to the query-string (s = "Carlo") a query with s.lowercase (see below), by which I get results merging the two queries, but of course I don't like it.
    Now, to add to my confusion, Xojo docs (@Spotlight) say that == is case insensitive.

    So I'd appreciate some light in order to come to a better understanding of this issue; i.e. querying "Carlo" or "carlo", how to get identical results that include all occurrences of Carlo and carlo.

    Thanks

    if TextField1.text <> "" then
      dim s as String = TextField1.text//"Carlo" or "carlo"
      dim mCompare as String = " ==[c] "   //or ==[d]; it should make a case insensitive query; but I get nil results.
      if CheckBox1.Value then mCompare = " == "   // it seems it makes a casesensitive query.
      Query.Query = "kMDItemDisplayName" + mCompare + """*" + s + "*""" + " || kMDItemDisplayName" + mCompare + """*" + s.Lowercase + "*"""
      //Query.Query = "kMDItemTextContent" + mCompare + """*" + s + "*"""
      end if
      Query.Run
    end if

    Edited: correction from "it should make a casesensitive query, but it does NOT" into "it seems it makes a casesensitive query".

or Sign Up to reply!