14 Replies Latest reply on Sep 12, 2011 10:48 AM by archdb

    further search within an already saved search

    archdb

      Title

      further search within an already saved search

      Post

      Hi,
      I need to search within an already saved search.
      I am not very familiar with scripts and I tend to get them wrong. So far I have managed to pretty much avoid them by using the searching option for multiple fields.
      However, I now need to select data within saved searches and I would gladly avoid creating new searches from scratch.

      I am mostly grateful for any suggestion/help with the matter. Thanks very much in advance!

        • 1. Re: further search within an already saved search
          Sorbsbuster

          You can select the 'Modify Last Find' from the Records menu, and then add/delete/modify the original criteria.

          The same function exists as a script step, if you want to script it.

          • 2. Re: further search within an already saved search
            Abhaya

            Hi,

            Just do one thing

            u may find record by script then go for constrain found set script step.

            means found upon found by script.

            it may be help you.

            • 3. Re: further search within an already saved search
              archdb

              Thanks you both!

              Suggestion by Sorbsbuster is what I have been doing so far but it is rather time consuming since my search involves having already put together 150 lines, therefore I need to modify each line every time I want to see how an item is doing within a different environment (i.e. add the field I want to interrogate) ...it is driving me nuts. 

              Suggestion by Atauf...I am not sure what you mean...I have tried "importing" search directly into script but when I get to second step in which I have to constrain analysis to only a field in relation to the 150 searched resuilts something does not work.

              Could you be more specific, sorry, I am really thick on scripts.

              At the moment I have:

              "run search [default settings]"

              "limit search to [default settings]"

              The first search does not present any problems but the whole script process stops there. 

              Am I missing something? Do I need to link the two? Is this possible?

               

              Thanks again!

               

               

              • 4. Re: further search within an already saved search
                LaRetta_1

                "it is rather time consuming since my search involves having already put together 150 lines, therefore I need to modify each line every time I want to see how an item is doing within a different environment (i.e. add the field I want to interrogate) ..."

                Hi archdb,

                It sounds like you have hard-coded data into your script so that it cannot be easily modified when you change criteria.  If so, enter your selections into global fields (maybe using Custom Dialog) and then perform your search for these entries instead.  But 150 lines of what?  Script?  I suspect that your structure is not normalized; either that or your script is doing a lot that it doesn't need to do.

                run search [default settings]"

                "limit search to [default settings]"

                Essentially, after Run Search finishes and you have a found set of records and it fires Limit Search, Limit Search needs to be within a Constrain Found Set (suggested above by Atauf).  We would need to see the Limit Search script (preferrably both) to be more specific.  It would also help to understand the context in which this process is ran. 

                • 5. Re: further search within an already saved search
                  archdb

                  Hi all, and thanks for your posts. 

                  My db has been built to collect and analyse data relating to finds coming from an archaeological excavation. Each artefact has fields with record excavation contexts/layers. The db has 9000 artefacts (4 different sub-categories).  Attributes pertaining to each artefact (e.g. length, width, colour, decoration type, raw material type etc., each a table itself with fields of its own), vary depending on the artefact category, however the maximum number of attributes for any artefact is 42. Last thing that makes things complicated (I believe): most fields refer to a table with a variable number of fields organised with a number ID corresponding to a description (e.g. 0=not identifiable; 1=raw material A; 2=raw material B). 

                  Problem: I need to search for a given artefact attribute (or more attributes at once): 

                  - among all records (easily done with standard search option);

                  - among a selected number of contexts/layers

                  - after this last search I would like to be able to further narrow down or modify search by e.g. looking how an attribute behaves within that set group of records.

                   

                  150 lines of script, yes. Since I need to specify in which layers I want the db to search, in this istance they are 150 different combinations of three different fields (Area, Context, Feature). 

                  I have already gone through the identification of different groups made of a number of contexts/layers. I have saved them all as individual searches. I would like to be able to use them to search within them. 

                  Since I could not find my way round it in search mode, I have:

                  1.run selected search (e.g. group A)

                  2.created a script with "run search []". Here when I go to select search the one just run appears by default (I only need to select all lines and add them to the script table). And so far so good: the script provides the search results.

                  3.created another script with "limit selected group []". Here, for instance, I want the db to look which of the selected record has a type A decoration. Therefore I select appropriate table and ID; e.g.: Decoration::=1 (since 1=decoration A).

                   

                  Second script does not work. If I re-design search everything works wonders but it is of little use and stupidly time consuming. 

                  In theory, I would like to be able to create searches or selections within which I can further look for fields that where not specified in that particular search. E.g. After having created a group of 10 contexts, I want to see which artefacts come from those context and...which raw material they are, which raw material and decoration, whcih raw material, colour and decoration.

                  At the moment I am exporting selected data in excel and I do it there, but since I have got through the pain of building a db I would like to use it.

                  Apologies for the lengthy explanation but perhaps things are clearer now...Forgot to say ( by now however is pretty obvious I believe): it is my first DB and my background is in humanities ...ehm.

                  THANK YOU! 

                   

                  • 6. Re: further search within an already saved search
                    LaRetta_1

                    "Forgot to say ( by now however is pretty obvious I believe): it is my first DB and my background is in humanities ...ehm."

                    You are doing very well.  Laughing

                    But we need to see your file.  If you can upload it somewhere (with a few dummy records or smart ones for that matter) then provide a link to it here.  If you are not comfortable with doing that then let me know and you can send your file directly for me to review.  It is best then to return to this thread and finish the overall discussion so that others, landing here with same issues, can see what we did.

                    I still suspect in my gut a lack of normalization here ... after all, you are background humanities and I am background databases. ;-)

                    • 7. Re: further search within an already saved search
                      archdb

                      Thank youuuuu! 

                      I have uploaded the db onto sendspace, here is the link

                      http://www.sendspace.com/file/t9l07n

                       

                      Any help/suggestion will be greatly appreciated.

                      Best

                      • 8. Re: further search within an already saved search
                        Sorbsbuster

                        Here's my penny-worth on a couple of side issues:

                        - I think you have used tables to create a lot of IDs and Descriptions which I think may have been just as well served by creating a Value list.  If that's the case it would have made your relationship graph much easier to manage.  Also your layouts list.

                        - Your find script is sort-of self-defeating by having two 'Perfrom Find' steps in a row - the second one will just completely over-write the first.  Did you mean that to operate as the equivalent of manually entering a find request, then adding a second request?

                        • 9. Re: further search within an already saved search
                          archdb

                          Hi Sorbsbuster, and thanks!

                          I appreciate your first comment and I understand it since I have struggled with it since the very beginning. I wanted to have a mask with drop down menus with texts (I suppose these are the value lists you mention) linked to numbers to be displayed in the db fields. This choice I thought would be good for two reasons:

                          1. I could translate mask into another language without having to touch fields directly.

                          2. when visuallizing the db in excel-like mode or when having to export it in excel I could have had columns with numbers rather than text. 

                          But I did not succeeded in creating one and this is what more or less works now...or at least it worked for data collection Embarassed

                          Anyhow...perhaps after I have finished my PhD I will take more time in going through it again and make it proper.

                           

                          Script: yes I meant to first enter a find request and then adding a second request. The latter should look into the results of the first one, but not necessarily the fields which have been already search through. Is that clear? I am afraid English is not my first language and it is awkward at times...

                           

                          Thank you in advance!

                          • 10. Re: further search within an already saved search
                            Sorbsbuster

                            Your English is perfect, don't worry about that.

                            Scenario 1

                            Two find requests are an OR search, so:

                            Enter Find Mode

                            Request 1 is Year = 2010

                            New Request

                            Request 2 is Country = Italy

                            will return you all records for the year 2010 (in any country) and all the records for Italy (in any year)

                             

                            Scenario 2

                            Two values in one request are an AND search

                            Request 1 is Year = 2010 and on the same Request Country = Italy

                            will return a list of those records where the record shows the country is Italy and on the same record the year is 2010

                            Scenario 2 will obviously return fewer records that scenario 1 (Oh, OK: if the only records for Italy are 2010 and the only 2010 records are all for Italy then they will be the same...)

                            Effectively in Scenario 1 the 2nd request adds more records to the found set.

                            In Scenario 2 the 2nd criterion (Country = Italy) searches within the first search (Year = 2010)

                            • 11. Re: further search within an already saved search
                              LaRetta_1

                              Archdb said, "I would like to be able to create searches or selections within which I can further look for fields that where not specified in that particular search. "

                              Then you want to EXTEND your found set which is saying, "Find me all of the records from the first find.  And now ALSO find me the records from the second find and combine with the first."

                              To do it, open your script and select script-step Constrain Found Set and insert into your script after your original Perform Find[]. Click 'specify request' and your second Perform Find[] criteria should still be listed there (Core 1).  Then for testing, just keep but disable the second Perform Find[] so you don't loose that long list of criteria.

                              Sorbsbuster nicely explained the difference between an AND and an OR search.  And now you know how to EXTEND the existing set of records as well.  This is also how you use the CONSTRAIN found set that I mentioned above (which will find within the existing found set).  So with Extend, you will end up with all the records from first find and all the records from second find as well. :^)

                              • 12. Re: further search within an already saved search
                                LaRetta_1

                                Since you are creating EXTEND searches, you can create each 'core' search separately then reference them as sub-scripts, something like:

                                Perform Script [ FIND Core1 ]
                                Perform Script [ FIND Core3 ]

                                ... etc

                                This will allow flexability with the numerous finds that you need to create, allowing mix and match.  I should also mention that this (or these) scripts should be properly error trapped.  Before each Perform Find[] and each Extend[] or Constrain[], use this script step:  Set Error Capture[On].  Then immediately after the last 'find' step, check if no records found.  It might look like this:

                                Set Error Capture [ On ]
                                Perform Find [ restore ]
                                Extend Found Set [ restore ]
                                If [ Get ( LastError ) ]
                                ... no records found,
                                Show Custom Dialog [ "No records found." ]
                                ... Halt script or do whatever you wish if no records are found such as going back to original layout
                                End If
                                ... records found so enter the remaining steps here.

                                The complexity of the error trapping would depend upon what you wish to happen if there are no results from the first request, the second and so on.  Set Error Capture [ On ] stifles the annoying 'no records found' dialog from FileMaker and allows you to make the script continue as you might wish.

                                • 13. Re: further search within an already saved search
                                  LaRetta_1

                                  Good grief, I made a major typo.  I said, "To do it, open your script and select script-step Constrain Found Set and insert into your script after your original Perform Find[]. "

                                  I meant select script-step EXTEND of course and not CONSTRAIN.  Sorry for the slip in words.

                                  • 14. Re: further search within an already saved search
                                    archdb

                                    Great! It works!

                                    I am playing with it right now and you both have done wonders!

                                    Thank you very much. I find the solution suggested by LaRetta really smart...I would never have got there (and it took me a bit to figure it out...ah ah...db & myself two different worlds!). Perhaps because I had already set a good number of searches it is rather easy to set "Perform find" script for them and retrieve already run searches scripts. Thank you!

                                    Thanks to sorbsbuster too, I thought I had understood the difference between or & and, but in practice I had made a mess...so thanks 1 million!

                                    I must admit I have not tried with "set error capture" on... I will do perhaps but at the moment it does not represent a problem to see that there are no records (in itself it is indeed important info for me!).

                                    thank you again!