We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    Can i restrict the pages that AjaxSearch searches?

    Also, can i run two different installs of Ajax Search on the same site?

    IE I want to use one search for my main site and a separate search for my blog pages.
      Content Creator and Copywriter
      • 19369
      • 1,098 Posts

      Can i restrict the pages that AjaxSearch searches? Link: http://wiki.modxcms.com/index.php/AjaxSearch

      Yes, with "&documents" or "&parents" parameter


      Also, can i run two different installs of Ajax Search on the same site?
      IE I want to use one search for my main site and a separate search for my blog pages.

      I think it should work.
        • 5811
        • 1,717 Posts
        Can i restrict the pages that AjaxSearch searches?

        Extract from ajaxSearch_readme.txt: To search in some documents:
        ---- &parents [ [ in | not in ] : comma separated list of Ids | '' ] (optional)
                A list of parent-documents whose descendants you want searched to &depth depth when searching.
                All parent-documents by default
             e.g:
             &parents=`in:24,25` 	- do the search in the children documents of documents 24 and 25
        
             &parents=`not in:24,10` - do the search in all documents except in the children documents of documents 24 and 10 documents
        
             &parents=`24,25`  means &parents=`in:24,25` (compatible with the 1.8.4 release)
             &depth [ 0 < int ] Number of levels deep to retrieve documents
        
             
        ---- &depth [int] (optional)
                Number of levels deep to go.
                Any number greater than or equal to 1. 10 levels by default
        
        
        ---- &documents [ [ in | not in ] : comma separated list of Ids | '' ] (optional)
                A list of documents where to search
             e.g:
             &documents=`in:28,29,30,31` 	- do the search in the documents 28,29,30,31
        
             &documents=`not in:28,29,30,31` - do the search in all documents except in documents 28,29,30,31
        
             &documents=`28,29,30,31`  means &documents=`in:28,29,30,31` (compatible with the 1.8.4 release)



        To exclude some documents from the search:
        ---- &filter : exclude unwanted documents      (optional)
                &filter runs as the &filter Ditto 2.1 parameter.
                (see http://ditto.modxcms.com/tutorials/basic_filtering.html)
        
                &filter=`field,criterion,mode`
        
                Where:
        
                "field" is the name of any field from main table (site content) or joined table (jot,  maxigallery) or a tv name
                "criterion" is a value of the same data type (number, string, date, etc.) as the field.
                "mode" is a number from 1 to 8 that specifies what kind of comparison to make
                    between the value of the field and the specified criterion.
                "," (comma) is the "Local Filter Delimiter", i.e. the character that tells
                    where the division is between the three parts of the clause.
        
                There must be no spaces in the "criteria" term unless you want them used in the comparison.
        
                The filter clause: id,50,2  means "exclude any document whose id field equals 50."
                The filter clause: articleTags,volcano,7  display only documents related to volcanoes (tv name = articleTags)
        
                A filter may include multiple clauses, separated by the global delimiter, in the form: clause|clause|clause|etc.
        
                Where:
        
                "clause" is any filter clause as defined above.
                "|" (the pipe symbol) is the Global Filter Delimite, the character that
                     tells Ditto where the division is between clauses.
                "etc." means there is no fixed limit to the number of clauses you may include.
        
                Multiple clauses have an "OR" relationship. I.e. a document will be excluded
                if it meets the criterion of any one clause (clause-1 OR clause-2 OR clause-3, etc.).
        
                The filter id,50,2|id,52,2 means "exclude any document whose id field equals 50 or 52."
        
                Comparison Modes
                Exclude a document if its value in the specified field
                1     is not equal to the criterion (!=)
                2     is equal to the criterion (==)
                3     is less than the criterion (<)
                4     is greater than the criterion (>)
                5     is less than or equal to the criterion (<=)
                6     is greater than or equal to the criterion (>=)
                7     does not contain the text of the criterion
                8     does contain the text of the criterion
                9     case insenstive version of #7 - does contain the text of the criterion
                10    case insenstive version of #8 - does contain the text of the criterion
        
                
            IMPORTANT : here the tv should be allowed as result with the withTvs or tvPhx parameters


        Also, can i run two different installs of Ajax Search on the same site?

        Extract from ajaxSearch_readme.txt:
        ---- &asId [ string | ''] - Unique id for AjaxSearch instance   (optional)
        
            Any combination of characters a-z, underscores, and numbers 0-9
            This is case sensitive. Default = empty string
        
            This parameter allow distinguish several Ajaxsearch instances on the same page
            The id is used to link the snippet calls between them. 
            Choose a short name. eg: "as2"

        You could also look at this post: http://modxcms.com/forums/index.php/topic,54396.msg314139.html#msg314139
          • 18367
          • 834 Posts
          Thanks

          smiley
            Content Creator and Copywriter
            • 18367
            • 834 Posts
            OK,

            manged to restrict folders but couldn;t restrict individual documents

            Here’s what itried

            &documents=`not in:19,20,100,223`


            also tried

            &filter=`not in:19,20,100,223`


            Where am i going wrong?

            Many thanks

              Content Creator and Copywriter
              • 18367
              • 834 Posts
              Can anyone shed some light on this?

              I still can;t get Ajax search to not search certainfolders and documents.

              Here’s my call

              [!AjaxSearch? &ajaxMax=`50` &extract=`90` &tplLayout=`optionSearch` &parents=`not in:56,63,224` &documents=`not in:19,20,100,223`  !]


              Using AS 1.9 and Evo.

              Thanks
                Content Creator and Copywriter
                • 5811
                • 1,717 Posts

                You can’t use simultaneously &parents and &documents. &parents override the &documents parameter.

                If it is possible for you, the better way to exclude the documents 19,20,100,223 is to define these documents as not searchable (property of a document)
                Then to exclude the children documents of 56,63,224, you could use &parents=`not in:56,63,224 or &filter=`not in:56,63,224`

                With &parents the chidren documents of 56,63,224 documents are excluded in the SQL statement.
                With &filter, the chidren documents of 56,63,224 documents are excluded after the execution of the Sql statement.

                See these demo pages for more informations.
                  • 18367
                  • 834 Posts
                  Too easy

                  Many thanks

                  grin
                    Content Creator and Copywriter