Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index map annotations (Fix #12318) #3383

Merged
merged 7 commits into from Feb 18, 2015
Merged

Conversation

joshmoore
Copy link
Member

In order for the name-value pairs attach to objects
to be searchable by Lucene, a handler for the map
annotations needed to be added.

To discuss/do:

To test:

  • Add a map annotation to an object and search for either the key or the value.
  • Additionally, searching for "key:value" should also return the object.

--no-rebase

In order for the name-value pairs attach to objects
to be searchable by Lucene, a handler for the map
annotations needed to be added.
@jburel jburel added the develop label Jan 23, 2015
if (nvs != null && nvs.size() > 0) {
for (NamedValue nv : nvs) {
if (nv != null) {
logger().error("{}={}", nv.getName(), nv.getValue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in progress" things to be removed before final merge, I guess

@joshmoore
Copy link
Member Author

Thanks, @mtbc. Pushed.

for (NamedValue nv : nvs) {
if (nv != null) {
logger().error("{}={}", nv.getName(), nv.getValue());
add(document, nv.getName(), nv.getValue(), opts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we want a standard prefix before map keys. (Even also using the map name, if it has a name?) So, they don't collide with other search field names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to entertain concrete suggestions. My thinking was that even a collision would still return proper search results. A prefix will require users to know to add it. Shrugs Both perhaps?

@dominikl
Copy link
Member

Search works like expected. I just wonder what the "map.key" is about.

@joshmoore
Copy link
Member Author

Using [ NamedValue("foo", "bar") ] as an example, without map,key

  • foo:bar would return a result and
  • bar (i.e. the default in _combined) would return a result

but foo alone would not. With map.key, the following all return:

  • foo:bar
  • bar
  • foo
  • map.key:foo

Is this useful?

@dominikl
Copy link
Member

Ah ok, yes, I think it makes sense; one would expect to find something by just searching for a name/key only.

@joshmoore
Copy link
Member Author

Would "has_key:foo" be better/clearer?

@joshmoore
Copy link
Member Author

@dominikl @pwalczysko @jburel @will-moore : any thoughts on this?

@pwalczysko
Copy link
Member

@joshmoore : Sorry, not sure about 2 things

  • does the user type this in the search box (e.g. has_key:foo ) ?
  • not sure what the difference between has_key:foo and map.key:foo really is (seems a bit the same ?)
  • searching for foo:bar (or rather in more realistic terms temperature:37 is the main case to cater for in my opinion -> we shouild not make the user to have to know the whole syntax with the colon, the search for temperature 37 or similar should give him something as well

@will-moore
Copy link
Member

If I search for foo=bar would I get key:value of foo: blah in my search results? If so, is it guaranteed to come AFTER foo: bar in the results?
What's the difference between searching for foo:bar and foo=bar?

@will-moore
Copy link
Member

Do we need any changes on the client side for this PR? Any changes in how we parse queries?

@joshmoore
Copy link
Member Author

Do we need any changes on the client side for this PR? Any changes in how we parse queries?

I don't think so. The only thing you would need to decide is if you ever want to work with has_key.

If I search for foo=bar would I get key:value of foo: blah in my search results? If so, is it guaranteed to come AFTER foo: bar in the results?

Do you mean foo=bar or foo:bar? I haven't done anything to support the former. If you're saying the client will parse out the "=" and therefore this will actually search for "foo bar" then yes, you could also get results for "foo blah" and there's no guarantee as to the ordering, though in general, I'd assume more matches come earlier.

What's the difference between searching for foo:bar and foo=bar?

The former is proper Lucene syntax. The second (if it works) is an odd by-product of our string parsing.

does the user type this in the search box (e.g. has_key:foo ) ?

I'm not sure if that's allowed by the clients, but certainly on the CLI you could type this to find all images that have a certain key. (At the moment, map.key:foo though). Alternatively, just foo would also return those images.

not sure what the difference between has_key:foo and map.key:foo really is (seems a bit the same ?)

Yes, it's just the question of which name is most understandable.

searching for foo:bar (or rather in more realistic terms temperature:37 is the main case to cater for in my opinion -> we shouild not make the user to have to know the whole syntax with the colon, the search for temperature 37 or similar should give him something as well

I believe this to be the case, yes.

@pwalczysko
Copy link
Member

@joshmoore : Thanks. has_key:foo sounds more understandable.

@joshmoore
Copy link
Member Author

Pushed.

@dominikl
Copy link
Member

If I understood this right, the name "map.key" or "has_key" doesn't matter on the client side (just an issue on the backend), so there's nothing specific to test for that in the clients, right?
If so, this PR is good to merge. Checked the search functionality again; search results are like I would expect. And I can confirm, if I search for "foo:bar" (or "foo=bar", doesn't matter because it's reduced to "foo bar" in both cases), it will find results where key=foo and value=bar, as well as results where just key or value=foo respectively where just key or value=bar; but results which contain both terms come first.

@joshmoore
Copy link
Member Author

Just to be clear: so there's currently no way to make use of "X:" from the clients at the momonet? i.e. it's parsed away?

@dominikl
Copy link
Member

Yes, at the moment all non-alphanummeric characters (except _ are replaced with a space). Ok that actually means I didn't understand this right, "has_key:xxx" is an expression the user should be able to type in order to search for a specific key only?

The expectation is that if "has_key:foo" is
passed that this would only find fields with
exactly that key. Though the LuceneQueryBuilder
removes the ":", the queries still seem to work
as expected.
@joshmoore
Copy link
Member Author

For me all the tests are now green. I pushed a few more to looking into #3383 (comment) (namely joshmoore@9b22776) which all seem to be fine. (Minimal) documentation has been opened. Assuming we don't want to start indexing more in this PR, I'd say it's good to go once the next run of the integration tests are green unless there are any questions/objections on the client-side.

@joshmoore
Copy link
Member Author

NB: re: "Which other map columns to index?" -- the only other 2 objects which would be useful to index onto the image would be the GenericLightSource and ImagingEnvironment. At the moment, though, we haven't done anything with those objects, so likely that would be more effort than we want to expend.

@joshmoore
Copy link
Member Author

Comment fixed. As I said, my assumption is that all these tests are green. If it's better to have this in m4, I'm happy to handle any test adjustments in subsequent PRs.

sbesson added a commit that referenced this pull request Feb 18, 2015
Index map annotations (Fix #12318)
@sbesson sbesson merged commit e501d4e into ome:develop Feb 18, 2015
@sbesson sbesson added this to the 5.1.0-m4 milestone Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants