Prepares a search results using given criteria in xml format.

Syntax

Visual Basic (declaration)
Public Function Search( _ 
ByVal AuthenticationTicket as String, _ ByVal xmlcriteria as String, _ ByVal SortBy as String, _ ByVal AscendingOrder as bool) as XmlNode

C# (declaration)
public XmlNode Search( 
string AuthenticationTicket, string xmlcriteria, string SortBy, bool AscendingOrder)

Parameters

AuthenticationTicket
    string infoRouter ticket
xmlcriteria
    string The xml structure of the criterias. To Details of this parameter see the remarks section.
SortBy
    string Possible Sort Options : DOCUMENTNAME, DOCUMENTSIZE, MIMETYPEDESCRIPTION, MODIFICATIONDATE, STATUSCODE, FOLDERNAME, LASTVERSIONNUMBER, PERCENTCOMPLETE, CREATIONDATE, MODIFIEDBYNAME, DESCRIPTION, OWNERNAME, FLOWNAME, VIEW, CHECKEDOUTBYNAME, COMPLETIONDATE, IMPORTANCE, RETAINUNTIL, CLEVEL, DECLASSIFYON, DOWNGRADEON, DISPOSITIONDATE, LASTISOREVIEW, NEXTISOREVIEW
AscendingOrder
    bool Boolean value can be true or false

Return Value

returns xml fragment.
<response success="true" error="" ranksorted="False">
if success attribute is "true", the search result has been prepared successfully.
if success attribute is "false", the error attribute indicates the encountered error.
if ranksorted attribute is "true" the results are always ordered by rank.
This occurs in cases where keyword criteria are specified.

Remarks

The Search Criteria XML fragment should be as described below.

<SEARCH>
<ITEM NAME="SEARCHSCOPE" VALUE="" />
<ITEM NAME="KEYWORDS" VALUE="" />
<ITEM NAME="DOCUMENTNAME" VALUE="" />
<ITEM NAME="DOCUMENTID" VALUE="" />
<ITEM NAME="FOLDERDESCRIPTION" VALUE="" />
<ITEM NAME="DOCUMENTFORMAT" VALUE="" />
<ITEM NAME="SEARCHFOR" VALUE="" />
<ITEM NAME="USERNAME" VALUE="" />
<ITEM NAME="FOLDER" VALUE="" />
<ITEM NAME="CHECKOUTSTATUS" VALUE="" />
<ITEM NAME="DATECRITERIA" SUBTYPE="" OPERATOR="" VALUE="" />
<ITEM NAME="SIZEIS" OPERATOR="" VALUE="" />
<ITEM NAME="IMPORTANCE" OPERATOR="" VALUE="" />
<ITEM NAME="CLEVEL" VALUE="" />
<ITEM NAME="DOCUMENTTYPE" VALUE="" />
<ITEM NAME="VIEWCRITERIA" VALUE="" />
<ITEM NAME="DOCSRC" VALUE="" />
<ITEM NAME="DOCLANG" VALUE="" />
<ITEM NAME="DOCAUTHOR" VALUE="" />
<ITEM NAME="PROPERTYSETNAME" VALUE="">
<ATTR NAME="" OPERATOR="" VALUE="" />
</ITEM>
</SEARCH>

criteria details

SEARCHSCOPE

ONLINE - Online Only
ALL - All Documents
ARCHIVE - Archive Only
ONLINE-HIDDENS - Online including Hiddens

if this parameters not specified all documents will be searched.

KEYWORDS : One or more keywords. This will invole a content (full-text) search.

DOCUMENTNAME : Name of the document. You may use an asterisk (*) to indicate that you have specified a partial document name.
such as
Acc*
*ing.doc
*.doc

DOCUMENTID: The ID of the document

FOLDERDESCRIPTION: The description of the folder.

DOCUMENTFORMAT: The format of the document. "DOCUMENTTYPE" is absolute used in Version 7.0
Possible pre-defined document formats are "Image", "Video", "Sound", "Office Document", "Internet Document", "Cascade Style Sheet", "Help File", "email message", "Compressed File", "Programming", "Plain Text", "Application", "Document Shortcut", "Internet Link", "XML Document"

Usage:
<ITEM NAME="DOCUMENTFORMAT" VALUE="Image,Sound" />

this criteria uses Mime type definitions specified in the inforouter control panel.



SEARCHFOR OR OBJECTTYPENAME: The options may be "FOLDERSONLY" or "DOCUMENTSONLY".

DOCTYPE


USERNAME : The name (username) of the user who owns the documents or folders to be returned.

FOLDER : Specify a folder path if you wish to limit your search to a specific path.

CHECKOUTSTATUS :
CHECKEDOUT - Restrict search to the CHECKED OUT documents
NOTCHECKEDOUT - Restrict search to the NOT CHECKED OUT documents

DATECRITERIA : Use this to restrict your search to a date criteria. See types below.

<ITEM NAME="DATECRITERIA" SUBTYPE="" OPERATOR="" VALUE="" />

the SUBTYPE attribute can be

CREATED : Date Created
MODIFIED : Date Modified
CREATED OR MODIFIED : Created Or Modified
RETAIN UNTIL : Retain Until
COMPLETED ON : Completed On
DECLASSIFY ON : Declassify On
DOWNGRADE ON : Downgrade On
LAST ISO REVIEW DATE : Last ISO Review Date
NEXT ISO REVIEW DATE : Next ISO Review Date
DISPOSITION DATE : Destroy Date

The Operator attribute can be
EQ
EQGT
EQLT
BETWEEN (requires infoRouter version 8.6.173+)

The Value attibute must be a date value in the Universal date format like 2005-04-23
use | character for BETWEEN operator

- search in to documents created before 1 feb 2005
<ITEM NAME="DATECRITERIA" SUBTYPE="CREATED" OPERATOR="EQLT" VALUE="2005-02-01"/>

- search in to documents created betweem 1 feb 2005 to 1 march 2005
<ITEM NAME="DATECRITERIA" SUBTYPE="CREATED" OPERATOR="BETWEEN" VALUE="2005-02-01|2005-03-01"/>

SIZEIS: Specify this parameter if you wish to limit your search to documents of a certain size.

OPERATOR can be
EQGT for at least
EQLT for at most

VALUE Attibute can be any integer value in the form of kilobytes

example:

<ITEM NAME="SIZEIS" OPERATOR="EQLT" VALUE="1024" /> searchs the documents smaller than 1 mb
<ITEM NAME="SIZEIS" OPERATOR="EQGT" VALUE="512" /> searchs the documents bigger than 512 kb

IMPORTANCE: Specify this parameter if you wish to limit your search to documents that are marked with a level of importance.

VALUE Attibute can be
LOW
NORMAL
HIGH
VITAL

OPERATOR attribute can be
EQ : Equal
EQGT : At least
EQLT : At most

example:

<ITEM NAME="IMPORTANCE" OPERATOR="EQ" VALUE="HIGH" /> searches the documents exacty set the high importance
<ITEM NAME="IMPORTANCE" OPERATOR="EQGT" VALUE="HIGH" /> searches the high importance or vital documents

CLEVEL: Specify this parameter if you wish to limit your search to documents that have a classification attribute set.

VALUE Attibute can be

NOMARKINGS - No Markings
DECLASSIFIED - Declassified
CONFIDENTIAL - Confidential
SECRET - Secret
TOPSECRET - Top Secret


VIEWCRITERIA: Specifies the documents view state for the search
Value attribute can be
NOVIEW : Documents the caller has not viewed
UPDATED : Viewed but Updated Documents</option>
SAW : Viewed but Unchanged documents

DOCSRC: The source of the document.
DOCLANG : The language of the document
DOCAUTHOR : The Author of the document


PROPERTYSETNAME: XML fragment specifies the documents property set values
Value attribute can be any Property set name defined in inforouter
The sub items in this node defines the attribute names, operator and the value.

<ITEM NAME="PROPERTYSETNAME" VALUE="ADDRESS">
<ATTR NAME="ADDRESSTYPE" OPERATOR="EQ" VALUE="HOME" />
<ATTR NAME="STATE" OPERATOR="EQ" VALUE="NY" />
</ITEM>
The xml fragment above restrics the search results to the ADDRESS property set applied to documents or folders. And the address type must be HOME address and STATE field must be NY.

The OPERATOR list:

DATE Datatype
ANYTIME,
YESTERDAY,
TODAY,
LAST7DAYS,
NEXT7DAYS,
LASTWEEK,
THISWEEK,
NEXTWEEK,
LASTMONTH,
THISMONTH,
NEXTMONTH,
EQ (requires a date value),
EQGT (requires a date value),
EQLT (requires a date value),
NULL,

NUMBER Data type
EQ (requires a number value)
NOTEQ (requires a number value)
EQLT (requires a number value)
EQGT (requires a number value)
GT (requires a number value)
LT (requires a number value)
NOTNULL,
NULL

CHAR Data type
LIKE (requires a string value)
EQ (requires a string value)
NULL,
NOTNULL,

BOOLEAN data type
EQ (requires a Boolean(TRUE,FALSE) value)
NOTNULL
NULL

minus gif Example

Visual Basic Example
Sub Search_sample()
        Const IRAuthenticationTicket as string="sid-xxxxxxxxxxxxxxx"
        Const Keywords as string="apple and pears"

        Dim IR_OBJ As InfoRouter.srv
        Dim xmlsearchcriteriadoc As System.Xml.XmlDocument
        Dim xmlcriteria As System.Xml.XmlElement
        Dim xmlResponse As System.Xml.XmlElement

        Try
            xmlsearchcriteriadoc = New System.Xml.XmlDocument
            xmlsearchcriteriadoc.LoadXml("<search/>")

            xmlcriteria = xmlsearchcriteriadoc.CreateElement("ITEM")
            xmlcriteria.SetAttribute("NAME", "SEARCHSCOPE")
            xmlcriteria.SetAttribute("VALUE", "ONLINE")
            xmlsearchcriteriadoc.DocumentElement.AppendChild(xmlcriteria)

            xmlcriteria = xmlsearchcriteriadoc.CreateElement("ITEM")
            xmlcriteria.SetAttribute("NAME", "KEYWORDS")
            xmlcriteria.SetAttribute("VALUE", Keywords)
            xmlsearchcriteriadoc.DocumentElement.AppendChild(xmlcriteria)

            ClearOutputWindow()
            Application.DoEvents()
            Me.ActiveForm.Cursor = Cursors.WaitCursor

            IR_OBJ = New InfoRouter.srv
            IR_OBJ.Url = (txtSrvUrl.Text & "/srv.asmx")

            xmlResponse = IR_OBJ.Search(IRAuthenticationTicket , _
                                        xmlsearchcriteriadoc.OuterXml, _
                                        1, True)
            If xmlResponse.GetAttribute("success") = "true" Then
                WriteOutputLine("The search prepared successfully.")


            Else
                WriteOutputLine("The search cannot be prepared.")
                WriteOutputLine("server response:" & xmlResponse.GetAttribute("error"))
            End If
            xmlResponse = Nothing

        Catch ex As Exception
            WriteOutputLine("error:" & ex.Message)
        Finally
            IR_OBJ = Nothing
            Me.ActiveForm.Cursor = Cursors.Default
        End Try
End Sub

C# Example
using System;
using System.Collections.Generic;
using System.Text;
using IRSearch.irwebservice;
using System.Xml;

namespace SearchSample
{
    class Program
    {
        static string _username = "sysadmin";
        static string _password = "pass";
        static string _wsURL = "http://docsrv/srv.asmx";
        static int _foundItemCount = 0;
        static void Main(string[] args)
        {
            srv ir = null;
            string ticket = "";
            try
            {
                writestatus("------------------------------------------------------------");
                writestatus("Connecting to infoRouter Server...");
                ir = new srv();
                ir.Url = _wsURL;
                writestatus("Connected.");
                writestatus("Authenticating...");
                XmlNode xResponse = ir.AuthenticateUser(_username, _password);

                if (getXMLAttributeValue(xResponse, "success", "").ToUpperInvariant() != "TRUE")
                {
                    writestatus("Authencatication failed!");
                    writestatus("Server Response:" + getXMLAttributeValue(xResponse, "error", ""));
                    return;
                }
                ticket = getXMLAttributeValue(xResponse, "ticket", "");
                writestatus("Authenticated.");

                writestatus("Searching...");
                if (!prepareSearch(ir, ticket))
                {
                    return;
                }

                _foundItemCount = 0;
                bool lastPage = false;
                while (lastPage == false)
                {
                    nextPage(ir, ticket, out lastPage);
                }
                writestatus("------------------------------------------------------------");
                writestatus("Found item count: " + _foundItemCount.ToString());

            }
            catch (Exception ex)
            {
                writestatus("ERROR:" + ex.Message);
                writestatus("DETAILS:" + ex.ToString());
            }
            finally
            {
                ir = null;
                Console.ReadKey();
            }
            return;
        }
        static bool prepareSearch(srv ir, string ticket)
        {

            string FOLDER = "/Corporate/Letters/";

            string qry = "<SEARCH>" +
                         "<ITEM NAME=\"SEARCHSCOPE\" VALUE=\"ONLINE\" />" +
                         "<ITEM NAME=\"FOLDER\" VALUE=\"" + xmlEncode(FOLDER) + "\" />" +
                         "<ITEM NAME=\"SEARCHFOR\" VALUE=\"DOCUMENTSONLY\" />" +
                         "<ITEM NAME=\"PROPERTYSETNAME\" VALUE=\"" + xmlEncode("ADDRESS") + "\" >" +
                         "   <ATTR NAME=\"" + xmlEncode("ADDRESSTYPE") + "\" OPERATOR=\"EQ\" VALUE=\"" + xmlEncode("HOME") + "\" />" +
                         "   <ATTR NAME=\"" + xmlEncode("STATE") + "\" OPERATOR=\"EQ\" VALUE=\"" + xmlEncode("NY") + "\" />" +
                         "</ITEM>" +
                         "</SEARCH>";

            XmlNode xResponse = ir.Search(ticket, qry, "DOCUMENTNAME", true);
            if (getXMLAttributeValue(xResponse, "success", "").ToUpperInvariant() == "TRUE")
            {
                writestatus("Search prepared.");
                return true;
            }
            else
            {
                writestatus("Search cannot be prepared.");
                writestatus("Server Response:" + getXMLAttributeValue(xResponse, "error", ""));
                return false;
            }
        }

        static bool nextPage(srv ir, string ticket, out bool lastpage)
        {
            lastpage = true;

            XmlNode xResponse = ir.GetNextSearchPage(ticket, false, false, false, false, false);
            if (getXMLAttributeValue(xResponse, "success", "").ToUpperInvariant() != "TRUE")
            {
                writestatus("Retrive failed..");
                writestatus("Server Response:" + getXMLAttributeValue(xResponse, "error", ""));
                return false;
            }

            lastpage = (getXMLAttributeValue(xResponse, "LastPage", "").ToUpperInvariant() == "TRUE");

            foreach (XmlElement xmlitem in xResponse)
            {
                if (xmlitem.Name.ToUpperInvariant() == "DOCUMENT")
                {
                    _foundItemCount++;
                    string docpath = getXMLAttributeValue(xmlitem, "Path", "");
                    string docname = getXMLAttributeValue(xmlitem, "Name", "");
                    int docid = Convert.ToInt32(getXMLAttributeValue(xmlitem, "DocumentID", "0"));
                    writestatus(docid.ToString().PadRight(10) + docpath.Replace("\\","/") + "/" + docname);
                }
            }
            xResponse = null;
            return true;
        }


        static void writestatus(string xStatus)
        {
            Console.WriteLine(xStatus);
            return;
        }


        static string xmlEncode(string xmlstr)
        {
            xmlstr = xmlstr.Replace("&", "&amp;");
            xmlstr = xmlstr.Replace("<", "&lt;");
            xmlstr = xmlstr.Replace(">", "&gt;");
            xmlstr = xmlstr.Replace("'", "&apos;");
            xmlstr = xmlstr.Replace("\"", "&quot;");
            return xmlstr;
        }

        static string getXMLAttributeValue(XmlNode xNode, string AttrName, string defaultvalue)
        {
            if (xNode == null) { return defaultvalue; }
            if (xNode.Attributes[AttrName] == null) { return defaultvalue; }
            string xValue = xNode.Attributes[AttrName].Value;
            if (xValue == null) { return defaultvalue; }
            xValue = xValue.Trim();
            if (xValue.Length == 0) { return defaultvalue; }
            return xValue;
        }
    }
}