Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ApplyQuery - ObjectId 1

Status
Not open for further replies.

annikan

Programmer
Aug 25, 2006
7
US
I would like to search from a folder and downward. Just how a user would search. So i'm assuming that ObjectId is the folder i wish to search???

"objectID the ID of the searchable object to which the search will be applied; the object must be a valid searchable object type. Open Text recommends that you search only SearchBroker objects. "

Searchable objects are: "Library Object, Livelink Index, and SearchBroker"

I'm guessing that a folder is a library object????

LAPI experts please help, i'm just baffled by this documentation.

Advance Thanks
 
You are correct. A folder is Library object. The library objects are the standard object types in Livelink such as documents, folders, projects, etc. I think in the early days of Livelink they used to call the Enterprise workspace the Library. That was the real early days!
 
That's good to know.
I found that I received an a get(name) error with the objectId being the folder id. However, if i put a negative sign in front of the objectId, i was able to call the search call.
I'm posting the code, because there isn't enought code examples out here.
Dim mynull As LLValue = (New LLValue).setAssocNotSet()
Dim session As LLSession
Dim documents As LAPI_DOCUMENTS

' Instantiate session object
session = New LLSession("oxflivelink", 2099, "", "me", "pass", mynull)

'Initialize any LAPI Objects
Dim doc As LAPI_DOCUMENTS = New LAPI_DOCUMENTS(session)

' Create Search Broker
' objectID the ID of the searchable object to which the search will be applied;
' the object must be a valid searchable object type. Open Text recommends that you search only SearchBroker objects.
Dim ObjectID_SearchBroker As Integer = -39496ObjectID

'Create select list
Dim selectList As LLValue = (New LLValue).setAssocNotSet()
selectList.setList()
selectList.add("OTObject")
selectList.add("OTName")
selectList.add("OTSummary")

'declare results Output Parameter.
Dim results As LLValue = (New LLValue().setTable())
'Create Where a query specifying the criteria to be used to retrieve the data.

'Call Query
Dim search As LAPI_SEARCH = New LAPI_SEARCH(session)
search.ApplyQuery( _
ObjectID_SearchBroker, _
selectList, _
"Jour de l’an", _
search.SORTBYEXISTENCE, _
"", _
1, _
100, _
"LivelinkQueryLanguage", _
results)


It works, now i'm attempting to extract the results from the LLValue object.
 
You basically put the results in a loop and extract the contents.Here's a smaple that serves as the lapi search bibe form OT.I just put some debugging stuff in there to help me understand it.It is in java not VB but you could always emulate the psuedo code in VB.The code also shows you ho you can get the brokers.The ocode is af it the user searched for livelink form the enterprise slice.I compiled this on a java 1.5 compiler and ran it against a LL running 9.5 sp1
Code:
//Java Sample using ApplyQuery
//code from OpenText
//David Templeton courtesy

import com.opentext.api.*;

public class ApplyQuery
{
	//For Connection
	private static String Server = "houlnkdev1";
	private static int Port = 2099;
	private static String DFT = "";
	private static String User = "llapi";
	private static String Pass = "llapi";

    public static void main( String[] args )
    {
        try
        {
            //variables
		   	LLSession 			session;
			LAPI_DOCUMENTS 		doc;
			LAPI_SEARCH			search;
			int					brokerID;

			//Constructors for session and search objects
			session = new LLSession (Server, Port, DFT, User, Pass);
			search = new LAPI_SEARCH (session);

			brokerID = GetSearchBroker(search, session);
			Search(brokerID, session, search);
		}


        catch ( Throwable e )
        {
            System.err.println( e.getMessage() );
            e.printStackTrace( System.err );
        }
	}


	public static int GetSearchBroker(LAPI_SEARCH search, LLSession session)
	{
		//Returns the BrokerID for the Enterprise Slice

		LLValue		vListBrokers, tmpAssoc;
		int			length, brokerID;
		String		nodeName, broker;

		broker = "Enterprise";
		brokerID = -1;

		//Define the value objects
		vListBrokers = new LLValue();	//List of available brokers
		tmpAssoc = new LLValue();		//Temp Assoc


		// Retrieve the Search Brokers
		if (search.GetSearchBrokers(vListBrokers) != 0)
		{
			System.out.println("Failed to get Search Brokers");
			sError(session);
		}
		else
		{
			//Find the Enterpise BrokerID
			length = vListBrokers.size();
			for (int i=0; i<length; i++)
			{
				tmpAssoc = vListBrokers.toValue(i);
				nodeName = tmpAssoc.toString("NodeName");
				System.out.println("Got this Broker"+nodeName );
				if (nodeName.equals(broker))
				{
					brokerID = tmpAssoc.toInteger("NodeID");
				}
			}
		}

		return (brokerID);
	}

	public static void Search(int brokerID, LLSession session, LAPI_SEARCH search)
	{
		//Use Apply query to Search for a specified term

		//Variables
		LLValue vSelectList, vQueryResults, value;
		String	where, fName;
		int length;

		//Define value objects
		vSelectList = new LLValue().setList();
		vQueryResults = new LLValue();
		value = new LLValue();

		//Set up the list of fields for ApplyQuery to return
		//Note: OTObject must be in this list for ApplyQuery to work
		vSelectList.add( "OTName" );		//Object Name
		//vSelectList.add( "OTDataID" );		//The objects ID
		vSelectList.add( "OTObject" );
		vSelectList.add( "OTOwnerID" );		//The objects VolumeID

		//Where clause which searches on the OTName region for the word "Livelink"
		where = "(OTData :\"Livelink\")";

		//Search Livelink
		if ( search.ApplyQuery( brokerID, vSelectList, where, search.SORTBYDEFAULT, "OTName", 0, 100, "LivelinkQueryLanguage", vQueryResults) != 0)
		{
			System.out.println("Apply query failed");
			sError(session);
		}
		else
		{
			//Displays the results of the search
			length = vQueryResults.size();
			if (length > 0)
			{
				System.out.println("The query returned "+ length+" results");
				for (int i=0; i<length; i++)
				{
					value = vQueryResults.toValue(i);
					fName = value.toString("OTName");
					System.out.println(fName);
				}
			}
		}
	}

	private static void sError(LLSession session)
	{
		//Error Checking
		System.out.println("Status Code: " + session.getStatus());
		System.out.println("Api Error: " + session.getApiError());
		System.out.println("Error Message: " + session.getErrMsg());
		System.out.println("Status Message: " + session.getStatusMessage());
	}



}

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
It might help you to know this also.Livelink has a powerful feature called the search XML API which is much more easier to fathom and only requires a rudimentary knowledge of XML data structures.With that you could probably get by without even doing any LAPI calls.I actually preferred that over lapi search.There is a very well documented search xml api guide by OT which is supposedly written for 9.6 but it has been there all along so it will pretty much work on earlier versions as well.
This thread almost has a fully working sample awesome stuff...
Code:
[URL unfurl="true"]http://tek-tips.com/faqs.cfm?fid=3552[/URL]
I always base line my search interfaces with this code replacing controls that I don't want to show the user with "hidden" html controls.Please also visit the livelink wiki area in online.opentext.com web site.There is a lot of increased activity there.A good place to see if somebody has placed some good examples.I have posted some samples ( I became a recent C# convert with my new job)and I see my good friend Greg also has some.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
I agree with appnair. The Search API combined with some LQL (Livelink Query Language) is pretty powerful and can be much simpler than LAPI.
 
Thanks guys,
If you are talking about the search xml that is done by calling a url and returns xml, I did take a look at it and I was concerned about returning too much data via xml. Does anyone have any input on the relative speed of the 2 methods?

I also choose to go the LAPI route because i need to extract some additional attribute information from each result return that I don't believe i can get from either ApplyQuery or the URL Method. So once i extract the results i'm then going to retrieve attribute info for each. This makes things much slower, so i need everything to be as fast as possible. it's already pretty slow.

I'm looking into some way of doing a "Get Next 20 results" Any ideas?
 
either lapi or xml api the speed is a relative concept.The search results are almost instantaneous.But the results have to be filtered against the permissions of the calling user that is what slows it down.Remember LL is a DMS and its search results have to honor the permission set of the users/groups which probably none of the other engines need to worry about.start at and go for wouldn't it give you what you are looking for .If you have direct database access then the llattrdata table has all the attribute information and the id of the objects that you are after.Also I belive if you know what category/att you are after you can query livelink thru xml,lapi etc etc.Read upon complex queres in LL help and the LQL syntax.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 

annikan you said:

"at it and I was concerned about returning too much data via xml"

The search api returns the data you describe in the display options to return. It is not much different then calling the LAPI interfaces, just looks and feels like more :)

That being said the attributes is another story, when the xml results returns the attribute data you are looking for it can actually be faster. Using the LAPI methods means an extra series of hits on the RDB for each object to retrieve the attr data, the ones in the XML come from the search engine directly and if the user search for attribute data will reflect the actual values searched. no additional hits needed.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top