1 2 Previous Next 19 Replies Latest reply on Oct 1, 2009 11:42 AM by wmixter

    Global Search Capabilities

    wmixter

      Title

      Global Search Capabilities

      Post

      I have written a script for a global search fuction that will find information from any field in any record using one search box. I have discovered; however, that if I type multiple entries into the box for one search, it will not pull records that meet all the search words but in different fields. For example, if a given record looked something like this:

       

      Title: Seinfeld

      Category: Sitcom

      Length: 30 minutes

      Keywords: Jerry Seinfeld, funny, new york city

       

      And then I type into my search field 'new york sitcom' it will not find this record. If I type either  'new york' or 'sitcom' it will find the record. Is there a way to fix this so that more detailed searches will still find these relevant records?

       

      Thanks! 

        • 1. Re: Global Search Capabilities
          philmodjunk
            

          You would need to create an additional "request" for each word in your field.

           

          Assuming your search text is in a global field:

          Set Variable [$i ; Value: 1 ]

          Enter Find mode []

          Loop

             Set Variable [$SearchWord ; Middlewords (table::globalsearch ; $i ; 1 )]

             Set field [table::Field1 ; $SearchWord]

             new record/request

             Set field [Table::field2 ; $SearchWord]

             #repeat for each additional field

            

             Set Variable [$i ; Value: $i + 1 ]

             exit loop if [ $i > wordcount(table::globalsearch)]

          End loop

          Perform find[]

           

          Edit note: Set Variable steps edited to more accurately reflect appearance in script editor.

          • 2. Re: Global Search Capabilities
            wmixter
               Should this script be embedded in my current global search script?
            • 3. Re: Global Search Capabilities
              philmodjunk
                

              I don't know for sure as I don't know what that script looks like.  :smileywink:

               

              Look over my example and compare it to your own. I think you can use my example in place of yours once you customize it to fit your specific table and fields.

              • 4. Re: Global Search Capabilities
                wmixter
                   Sorry, for some reason I'm experiencing more difficulty with this than expected. Where did the '1' come from in your Set Variable ([$i ; 1])?  When I make the Value 1, my script comes out in a different format ([$1; Value:1]). Is it not supposed to be a value? Sorry, hopefully this is my last question...
                • 5. Re: Global Search Capabilities
                  philmodjunk
                     Set Variable [$1; Value:1] is the correct format. I just failed to enter that detail when I typed things into the message. Sorry for the confusion.
                  • 6. Re: Global Search Capabilities
                    wmixter
                       Thanks so much! It seems to be working almost perfectly. My only issue now is that the global search seems to now be pulling records that contain any of the search words, in addition to the records that have contain them all. Is there a way to limit it to only finding the records that contain all of the search words?
                    • 7. Re: Global Search Capabilities
                      philmodjunk
                        

                      I see you want to have your cake and eat it too :smileywink:

                       

                      Your original script found records in that manner. Then you wanted to be able to search for records where only part of the text was in any given field--that's what the new script does. You'll need to either have two scripts with two buttons so that the user can choose which type of search they want or you'll have to create a more sophisticated script that will treat quoted groups of words as a single search word instead of multiple words.

                      • 8. Re: Global Search Capabilities
                        wmixter
                           I suppose I am being a little picky ha...but I just want to make sure I can do what I would like before I buy the real version (I'm currently using a trial version.) So I suppose what your saying is that there is no simple way to make my global search only pull out records that contain all the words in my search, even if they're dispersed among fields in that record?
                        • 9. Re: Global Search Capabilities
                          philmodjunk
                            

                          Another approach that may be much simpler all around occurs to me.

                           

                          Define a new calculation field and name it "AllText".

                           

                          Field1 & " " & field2 & " " & Field3 & .... /* include all fields you want to search */

                           

                          Now your search script becomes

                           

                          Enter find mode []

                          Set field [Table::AllText ; globalsearchfield]

                          Perform Find []

                          • 10. Re: Global Search Capabilities
                            comment_1
                              

                            wmixter wrote:
                            I suppose I am being a little picky ha...but I just want to make sure I can do what I would like before I buy the real version (I'm currently using a trial version.) So I suppose what your saying is that there is no simple way to make my global search only pull out records that contain all the words in my search, even if they're dispersed among fields in that record?

                            See if this helps:

                            http://www.fmforums.com/forum/showtopic.php?tid/201295/


                            • 11. Re: Global Search Capabilities
                              wmixter
                                 Ok, so I will apologize in advance for this post, as I'm sure my uber-nitpicky questions and requests are driving some of you crazy. Anyway, I was wondering if perhaps I could insert some sort of 'if' control into my global search script to limit my search results to records that contain all of the search words in various fields, and eliminate results with records that contain only some of the search words. Would something like this be possible? Like a 'if record does not include all searchwords, do not find' control?
                              • 12. Re: Global Search Capabilities
                                comment_1
                                   If you mean  find records that contain all the search words in any field, then I believe you'd be better off searching in a calculated "pool" field that concatenates all fields of interest.
                                • 13. Re: Global Search Capabilities
                                  wmixter
                                    

                                  It does not have to have all of the search words in one field. For example, lets say this is what a given record looks like:

                                   

                                  Title: The Wizard of Oz

                                  Category: Movie

                                  Year: 1939

                                  Actors: Judy Garland

                                  Keywords: Cowardly Lion, Tin Man, Yellow Brick Road

                                   

                                  Now, if I search "Wizard" and "Yellow"in my search box, I would like to find this record. My current global search fxn will find this record, but it will also find records that only contain "Wizard" and ones that only contain "Yellow" as well. Is there a way to eliminate them from my search results?

                                   

                                  • 14. Re: Global Search Capabilities
                                    philmodjunk
                                      

                                    I believe searching the concatentated calculatin field I described earlier will get you what you want. Using your last example, the calculation would read:

                                     

                                    Title & " " & Category & " " & Year & " " & Actors & " " Keywords

                                     

                                    Call that field cCombinedFields and script it as:

                                     

                                    Enter Find Mode []

                                    Set Field [cCombinedFields ; table::gSearchTextField ]

                                     

                                    Since you are no longer generating a separate request for each word, it should only find records where the entire contents of gSearchTextField are found somewhere in the listed fields.

                                    1 2 Previous Next