FlexSearch

by Joshua Willing

FlexSearch is Quick Find with super powers.

Sometimes Quick Find isn’t enough. Because it matches phrases from the beginnings of words it can miss valuable search results. Performing a Find is the natural response but many users find that process awkward.


FlexSearch solves this problem! It is a portable search bar that performs a Quick Find or “FlexSearch”, which matches phrases using the beginnings, middles and ends of words too. Users can easily turn FlexSearch on and off, or the developer can incorporate just one or the other.


FlexSearch is fast. For hosted files it actually outperforms Quick Find when searching long phrases because it performs the complex find on the server and replicates the found set on the client.

Dependencies

Hyperlist is required. The example file below contains Hyperlist so you can copy it from there if you don’t have it yet.

 

Download:

Download Module Version 1.0.3

Download Latest From Github

 

 

In the installation video below, please disregard the part that says UUIDs are required. The latest version works with any kind of id, including serial numbers.

Videos:

Intro

Installation

Suggestions welcome!

 

Version History:

  • 1.0.1. — 5-29-2017 — Adjusted the hide calculation in the flexsearch fields offscreen object to accommodate single field flexsearches. Thanks pleiades for pointing out the bug.
  • 1.0.2 — 6-7-2017 — rgordon pointed out that the module was creating 3 TIMES as many search records as needed. This should work even faster now. Thanks rgordon for the insight!
  • 1.0.3. — 8-6-2017 — Flexsearch now works with serial numbers instead of just UUIDs. Any id type will work as long as the id is unique within its own table.

39 responses to “FlexSearch”

  1. rlanthier says:

    Hi Joshua

    Very nice tool and easy to install.

    Can it work in a portal?

    rl

    • Joshua Willing Halpern says:

      Hey, glad you found it useful! Currently this does not filter portals, but I suppose a future version should do that.

  2. Shannon says:

    Nice!

  3. pleiades says:

    Hi Joshua!

    Would it be possible to put it in pop-up picker?
    https://filemakerhacks.com/2011/05/09/popup-pickers/

    I like to suggests flexsearch popup module for portals

    TIA!

    • Joshua Willing Halpern says:

      I haven’t tested it this way, though I’m sure it could be made to work if it doesn’t already! I’ll take a look when I have a free moment. And thanks for the article, I’ll have to check it out soon.

    • Joshua Willing Halpern says:

      Hey, I just opened the article you sent about popup pickers. I believe you should be able to install it on a popup picker already with no changes to the module. Simply create your picker layout, a button to open the picker, and a button on the list row to choose the record you want.

  4. _cato_ says:

    Hi Joshua,
    just tried your tool – good job! Easily implemented und fast!

    I have a little suggestion for the ScriptParameter that’s needed to start the search: Get(LayoutName) & “::id”
    So you can copy and paste the searchbar without having to adjust the ScriptTrigger.

  5. _cato_ says:

    Supplementary note to my previous post: I know – my suggested ScriptParameter only works, when the id field in every table is named “id”. And it breaks, if someone changes the name of an id field.

    But if you use consequently the same name for the id field, it’s less work to implement FlexSearch.

    • Joshua Willing Halpern says:

      I was going to say the same thing. I originally wanted to avoid script parameters altogether, and your method all but eliminates the hassle of having them. Good idea. Thanks for clarifying the risk of hardcoding the field name to anyone who might have missed that.

  6. pleiades says:

    Thank you for the reply Joshua!

    Hope you can make one for line items, it would make adding product to invoices very quick. Thank you!

    @_cato_
    I like to learn more of your technique, is the “id” the foreign or primary key? what if you have joins? do you need to rename them all to id?

    sorry, I’m learning filemaker on my spare time.

  7. _cato_ says:

    First of all, I have to correct myself: It would be better to use Get(LayoutTablename) & “::id”, because layout name and layout table name could be different … then Get(LayoutName) would not work to address the table of the actual layout.

    @pleiades
    All primary key fields in a solution should have the same name.

    I always name primary key fields in every table of my solutions “id” – like descripted here: http://filemakerstandards.org/display/cs/Naming+Conventions

    For foreign key fields I use the pattern “id_NameOfTheForeignTable”.

    This way you know in every context where to find the id and where to find the foreign id.
    Hope, this helps you a little bit …

  8. Byeng Han yoo says:

    hi. joshua!
    can i ask u about something?
    i always use invoices of filemaker Pro advanced. it is inconvenient to popover search in Add Line Item.
    I think flexsearch is better than the basic popover search.
    Is it possible to put flexsearch in instead of the basic popover search?
    IF it is possible, Please make it

    • Joshua Willing Halpern says:

      Hi Byeng,
      FlexSearch is designed to find records within lists and forms rather than filter portals like in the Invoice Starter Solution (to which I believe you’re referring). If you want to incorporate FlexSearch into your Add Line Item workflow, I recommend you make a Card Window picker layout with flexsearch on top. Base this layout on your products table and configure as you would normally configure flexsearch to search only the fields you want/need.

  9. plei says:

    Hi Joshua!

    The flexsearch module uses the guid using Get (GUID), I would like to connect it with an external database (MySql and MSSQL), the data in the external database are not editable and i cannot added another column for guid,

    Would it be possible to allow flexsearch to use other fields of the external database like a serial number if there is no guid?

    Thank you!

    • Joshua Willing Halpern says:

      Hey plei, I’m pretty sure you need to use UUIDs(GUIDs) if you intend to use the “FlexSearch” feature on a hosted file and not just the regular quickfind option. Look in the example file relationship graph in the green box. This is where you would put your searchable tables and when Flexsearch does a server-side search, it’ll scan these TOs when it gets back client-side to recreate the found set. Since serials can be duplicated over multiple different tables (e.g. table1,id1 and table2,id1) the script will not know which table to use.

      However, you’ve just given me an idea for an improvement that would do just that. If you want to do a modification that fixes this problem by all means, go ahead. Otherwise I will when I have some spare time in the future.

    • Joshua Willing Halpern says:

      Hey, the new version 1.0.3 will work with serial numbers (or any id type) as long as the id is unique within the table. Cheers!

  10. Peter says:

    Hi Joshua

    Just like to say thank you! – Very easy to install and use, and have obviously saved me a lot of time.

    Cheers
    Peter

  11. Joshua, first of all… thank you for this. Easy to install, works like a charm.
    Is there a way to limit the search to a subset? For example: Let’s say I have a list of contacts that reside in multiple cities across the country. Can I search for people named ‘Smith’ that have New York as a city in their address (where ‘city’ is a field)? So while I have 10 people named ‘Smith’ nationwide, I might have only 3 from New York.
    Thank you again for this wonderful module.

    • Joshua Willing Halpern says:

      Hi Lazarus, you’re welcome, I’m glad that you are finding this useful.
      As long as the module is searching the city field too, simply type “Smith New York” and you should get your desired result.

  12. The “City’ was an example (I guess it failed as such). I actuality it’s limiting the set by matching a field that has a particular UUID ( not the main ID ) – it’s a foreign key field. So, it’s searching the set constrained by a predetermined foreign key – or even better constrained by a variable that can be passed through.
    Thank you again.

    • Joshua Willing Halpern says:

      I understand now that you want to pre-filter by a certain field automatically, with no user interaction. This module does not currently support this but it would be an easy feature to implement. I’d pass in an array of JSON objects {fieldName, value, omitBoolean} which would be converted into find requests by the scripts. These would further filter any results returned. I don’t have time to implement this feature right now but it would be a very good addition for a future version.

  13. pleiades says:

    This feature would be amazing in Flexsearch. Hope to see this get implemented.

  14. pleiades says:

    Yes, that is what i was referring to. I’m not able to click on the Reply button.

  15. Bib says:

    Hi Joshua – Will this solution work searching related tables? I have set it up and FlexSearch is working however I cannot search for a unique value that I know exists in a related table for the record I am on.

    Table A >–< Table B
    Field1

    From Table A I want to search Table B via the relationship, please let me know if you need more information.

    • Joshua Willing says:

      Yes it should work searching related tables. Are you using the offscreen text objects to define the searchable fields (demonstrated in the installation video)?

      NOTE: for quickfind the field you’re searching must be on the layout somewhere, either onscreen or offscreen.

  16. pleiades says:

    @Bib

    I can confirm flexsearch works on related tables. I was able to make it work.

    @Joshua Willing

    Can I request the implementation of the pre-filter feature? I think it would be really great. Thank you!

    • Joshua Willing says:

      Ok, I started working on this. I’m looking to switch parameter passing to use JSON, which means that the next version will require Filemaker 16+. Also, any current installations will need to be updated to pass in JSON script parameters instead of unstructured text.

      Does that all sound fair?

  17. pleiades says:

    Yay! looking forward to this! I think its fair since you have to add new features. For old Filemaker version, they can use the v1.0.3.

  18. rlanthier says:

    Hi Joshua,
    how close are you to uploading the new version?

  19. pleiades says:

    Hi Joshua,

    Sorry for the late feedback, I have tested it and the filtering works! Thank you!

    I have found that the new version is a bit faster than v1.

    I think I found a bug on v2 flexible searching
    Example:
    Searching for a product name: “Silver Fish”

    In v1 you can type ‘fis ver’ or ‘il is’ and it will find Silver Fish

    In v2 if you type ‘fis ver’ or ‘il is’, it will not find Silver Fish
    You have to type ‘ver fis’ to find it or
    You have to type ilver fis to find it.

    The bug is that v2 cannot find the record when the user typed search in a different order, the flexibility of searching is gone

  20. pleiades says:

    Hi Joshua,

    I’ve tested v1.0.3 and v2 and can confirm the flexible searching is lost

    I’ve changed Kiley to Kiley Kiley on both of the files

    In v1.0.3, you can search in any way like searching “Kil ‘space’ ey” will find the Kiley Kiley. even if I change the order like ” ey ‘space’ kil”, it will still find Kiley Kiley.

    In v2, searching using “Kil ‘space’ ey” or even “Kil ‘space’ ” will not find Kiley Kiley, you can start anywhere but the next letter should be in order, example you start on the ‘space’, the next letter should be K-i-l-e-y or it wont find it, and if you added an extra ‘space’ at the end, it wont be able to find it.

    Hope this helps in fixing the bug

  21. pleiades says:

    Hi Joshua,

    Further testing, I think the bug is in the looping and how they handle the spaces.

    In v1.0.3, whenever you search something with a space, it loops through each group of letters separated by the space, and in effect, the search result is more accurate

    In v2.0.0, it does not deal with any space, the result is it does not loop the find.

    Example ‘Kil ‘space’ ey”

    In v1.03, because of the space in the middle, it considers “Kil” and “ey” as two separate searches.
    First it searches “Kil” and then after that it then searches “ey”, and I’m not sure but then you combine it somehow?

    The result is even though you only know few letters of the word/words, you would still have a result.

    In v2.0.0, because it does not deal with the space, it just searches ‘Kil ‘space’ ey” as one search, that is why I think it can’t find the word “Kiley” because it does not have any space.

    The result in v2.0.0 is that you need to know the exact letters and how the word/words are ordered.

    Hope this helps.

  22. Aaron says:

    Does FlexSearch 2.0 work with FileMaker Webdirect?

  23. Nate James says:

    I can’t seem to reply either

    Pleidas I was having the same problem you where having too and I followed your trouble shooting and I have the fix
    Thanks for putting me on the right path 🙂

    in this script
    FlexSearch: Perform FlexSearch
    Line 57 — Set Variable [ $searchWords ; Value: Substitute ( FlexSearch::SEARCH ; ¶ ; “ ” ) ]

    The substitution is wrong and does not make a list. Its simply backwards. Our substitute should be looking for the space “ “ and substituting a ¶ or carriage return. This creates the list of words to look for

    So change the code to
    Set Variable [ $searchWords ; Value: Substitute ( FlexSearch::SEARCH ; ” ” ; ¶ ) ]

    variable $searchWords is now a list of values and works like a charm for me.

    Again thank you to Joshua for making a great tool.

Leave a Reply

Your email address will not be published. Required fields are marked *