Page 1 of 1

Lucene Index

PostPosted: Thu Feb 17, 2011 3:37 pm
by bhcho
Hi all,

1.
Does anyone have any idea to get all possible values of a specific key in Lucene Index by OMERO.script?
for example, I updated lucene index for an image with a key/value pair of "A.B.C1" and "BK".
And for another image, I added "A.B.C1" and "Bob" pair to lucene index.

So, I want to populate all possible values for "A.B.C1" to a drop-down box in my own script so that users can easily select one of them.


2.
Is it also possible to query the regular ome-xml fields from OMERO.script?
for example, is it possible to retrieve all images that has "Objective"'s "nominal magnification" as "40"?


Thanks in advance,
BK

Re: Lucene Index

PostPosted: Thu Feb 17, 2011 4:24 pm
by jmoore
Hi BK,

there is currently no way to retrieve all values of a key from OMERO.search. I've added ticket 4413 if you would like to track its implementation. Currently it is unscheduled, but we will likely be working heavily on search for OMERO 4.4.

It is possible to query for objectives with nominal magnification of 40, but not yet to search for images with objectives of nominal magnification 40 as I mentioned under http://openmicroscopy.org/community/viewtopic.php?f=6&t=478&p=1485&hilit=nominal#p1486. That comment points to ticket 2953, but as I mentioned there, you can also set these fields from your own bridge.

Cheers,
~Josh.

Re: Lucene Index

PostPosted: Thu Feb 17, 2011 4:36 pm
by wmoore
Hah - Josh beat me to this one. Here's what I was going to post...

I can only answer your second question just now...
Since the nominal magnification will be in the objective database table, you can search for matching images using a custom query from the query service...

Code: Select all
nominalMag = 40

params = omero.sys.Parameters()
params.map = {"nomMag": rint(nominalMag)}
query = "select i from Image i join fetch i.objectiveSettings as objS join fetch objS.objective as ob where ob.nominalMagnification=:nomMag"

# if you don't need to retrieve the objective itself, you can leave out the 'fetch' like this...
#query = "select i from Image i join i.objectiveSettings as objS join objS.objective as ob where ob.nominalMagnification=:nomMag"

images = qs.findAllByQuery(query, params);

for i in images:
    print i.getName().getValue()
    # if you have 'fetched' the objective above, you will have that data
    print i.objectiveSettings.objective.manufacturer.val
    print i.objectiveSettings.objective.lensNA.val


Hopefully someone else can help with the Lucene query. But I should warn you that setting options in one of the parameters of a script cannot be done before the script is run. Once the script has started running (and you do your Lucene query) you cannot then set the options for a parameter and present that UI to a user. There is no user interaction in the scripting service. It's fire and forget!

Will.

Re: Lucene Index

PostPosted: Mon Apr 23, 2012 6:18 pm
by icaoberg
is it possible to retrieve the magnification from an image object using the existing API?

ivan

Re: Lucene Index

PostPosted: Mon Apr 23, 2012 8:09 pm
by wmoore
Just editing the example above you can do

Code: Select all
params = omero.sys.Parameters()
params.map = {"iid": rlong(imageId)}
query = "select i from Image i join fetch i.objectiveSettings as objS join fetch objS.objective as ob where i.id=:iid"

image = queryService.findByQuery(query, params);
print i.objectiveSettings.objective.nominalMagnification.val