Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Mediabin custom search
Shete
Hi,
I am trying to search images having 'Insertion Date' metadata value less than certain date. I am using following code but it's not returning any result. Can you please let me know if there is anything wrong?
This same code works nice for 'GreaterThan' search operator.
There are assets available in the system satiesfying both the criterias.
MBAsset[] searchResults = null;
const String MediaBin_MetaData_InsertionTime = "{5BE195E7-0726-11D3-9DDE-0060081F836F}";
try
{
//Create search critera and add metadata by passing the value for "Insertion Time" Metadata
MBSearchCriteria criteria = new MBSearchCriteria();
criteria.mContainerID = containerID;
criteria.mAssetID = null;
criteria.mRecursive = true;
criteria.mMaxHits = 1000;
MBMetadata metadataAsset = new MBMetadata();
metadataAsset.mName = "Insertion Time";
metadataAsset.mID = MediaBin_MetaData_InsertionTime;
metadataAsset.mValue = "21/07/2009 00:00:00 AM";
//Create search constraint assinging the above metadata values and
// set a SearchOperator with options present and set the
//boolean oprator to Not Set
MBSearchConstraint[] constraint = new MBSearchConstraint[1];
constraint[0] = new MBSearchConstraint();
constraint[0].mMetadata = metadataAsset;
constraint[0].mSearchOperator = "LessThan";
constraint[0].mBooleanOperator = MBBooleanOperator.NotSet;
criteria.mSearchConstraints = constraint;
// Perform the search
searchResults = _mediaBinServer.Search(criteria, false);
}
Find more posts tagged with
Comments
msrinivas
What do you mean by "metadata value less than certain date"? Is it before that date or after that date?
Shete
I mean before that date.
Thanks,
Shriram
Shete
any replies please?
Shete
I am stuck at this point
..It will be great if someone can reply.
msrinivas
If you are trying to search for assets that were ingested before a certain date then the correct search operator is GreaterThan.
Also, instead of using a hard typed date you can use something like DateTime.Now.AddDays(-intArchiveTime) where intArchiveTime is the archive time in days
HTH
vy8359
You need to convert the value to date/time type before passing it to the query
Shete
You need to convert the value to date/time type before passing it to the query
Thanks! It worked. Earlier I was passing Date in string format which was working with 'GreaterThan' operator but not with 'LessThan' operator. Now I pass value in Date format and it works for 'LessThan' operator.
merry
Hi All,
I am trying to explore MB APIs to get the search result using the Asset ID. I am able to connect to MB server.
I am facing a problem while using search criteria. Following is the code snippet. It would be very helpful if you can throw some light, why "NullPointerException" is hunting me
All the 3 lines at the bottom (2 of them are commented as of now) just gives this exception.
private static MBServer _server;
public static MediaBinServerSoap service;
MBSearchCriteria mbSearchCriteria = new MBSearchCriteria ();
String folderId ="";
MBContainer testContainer = service.getContainerByPath(
"\\Media Database\\subFolder1\\subFolder2\\subFolder3",
service.getRootContainer().getMID(),
false);
folderId=testContainer.getMID();
mbSearchCriteria.setMContainerID (folderId );
mbSearchCriteria.setMRecursive(true);
mbSearchCriteria.setMMaxHits(10);
mbSearchCriteria.setMAssetID(null);
MBMetadata mbMetadata = new MBMetadata ();
mbMetadata.setMName ("Any Text");
mbMetadata.setMID ("16D82CEC-B515-4768-A412-829E158EFC37"); //Asset ID for one of the asset within the folder
mbMetadata.setMValue (1); // Referred devnet thread and got to know that 1 is for JPG
MBSearchConstraint constraints[] = new MBSearchConstraint[1];
constraints[0]=new MBSearchConstraint ();
constraints[0].setMBooleanOperator(MBBooleanOperator.NotSet);
constraints[0].setMMetadata(mbMetadata);
constraints[0].setMSearchOperator("contains");
//ArrayOfMBAsset serResult = service.search(mbSearchCriteria, true);
//ArrayOfString serResult2 = service.search_GetAssetIDsOnly(mbSearchCriteria);
_server.setSearchConstraints(constraints, mbSearchCriteria);
Rick Poulin
Please start a new thread next time. This doesn't have anything to do with the rest of the thread.
BTW, you're getting a NPE because nowhere in this code have you initialized service and _server. In the last three lines, only those variables could be throwing the NPE (assuming it's not being thrown from inside those calls, but your stack trace should be telling you where to look).
merry
Thanks for your reply.
Thought of updating this thread, as it was also related to Search API.
Not sure, if I got what you are saying regarding initialization
I am able to invoke service.getMediaBinServerName() successfully for the service I am using.
Would really apriciate any pointer in this regard.
Rick Poulin
If that call works, then this one [service.search(mbSearchCriteria, true);] should not be throwing an NPE on this line, but perhaps on something inside the call. Post your stack trace.
merry
Thanks for ur response. Following are the 3 lines I have used in d java and getting the Error mentioned below. Left most are the line numbers.
142 ArrayOfMBAsset str1 = service.search(mbSearchCriteria, true);
143 MBAsset[] a = str1.getMBAsset();
144 System.out.println("Length : " +a.length);
Exception in thread "main" java.lang.NullPointerException
at com.hilton.teamsite.ConnectMediabin.main(ConnectMediabin.java:143)
Thanks.
Rick Poulin
Ok, so that means str1 is null. I don't have the API in front of me to figure out why the search() method returned null instead of an empty array, but I'd guess that you mbSearchCriteria are somehow invalid or missing something.
If you're lucky, the web service log on the MB side might help you figure that one out.
merry
Do I need to refer MBP.log?
Rick Poulin
Well MBP.log is the log for MediaBin itself. You may very well have something useful in there, so it's worth checking. However the log I was referring to is specific to the Web Service. Sorry, I don't remember the exact name of the log and I don't have an instance available to check atm.
merry
Thanks Rick for ur help.
Nothing helpful in MBP log
.
Can anyone guide me with the path for Web Services log.
Thanks.