-
Notifications
You must be signed in to change notification settings - Fork 100
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
Changes from 2 commits
09fda64
87ce619
83dd361
f83f5ee
18b76a4
9b22776
7d02b16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,13 @@ | |
import ome.model.IObject; | ||
import ome.model.annotations.Annotation; | ||
import ome.model.annotations.FileAnnotation; | ||
import ome.model.annotations.MapAnnotation; | ||
import ome.model.annotations.TagAnnotation; | ||
import ome.model.annotations.TextAnnotation; | ||
import ome.model.annotations.TermAnnotation; | ||
import ome.model.core.OriginalFile; | ||
import ome.model.internal.Details; | ||
import ome.model.internal.NamedValue; | ||
import ome.model.internal.Permissions; | ||
import ome.model.meta.Event; | ||
import ome.model.meta.Experimenter; | ||
|
@@ -205,8 +207,10 @@ public void set_annotations(final String name, final IObject object, | |
} | ||
} else if (annotation instanceof FileAnnotation) { | ||
FileAnnotation fileAnnotation = (FileAnnotation) annotation; | ||
handleFileAnnotation(document, opts, | ||
fileAnnotation); | ||
handleFileAnnotation(document, opts, fileAnnotation); | ||
} else if (annotation instanceof MapAnnotation) { | ||
MapAnnotation mapAnnotation = (MapAnnotation) annotation; | ||
handleMapAnnotation(document, opts, mapAnnotation); | ||
} | ||
} | ||
} | ||
|
@@ -216,7 +220,9 @@ public void set_annotations(final String name, final IObject object, | |
if (object instanceof FileAnnotation) { | ||
FileAnnotation fileAnnotation = (FileAnnotation) object; | ||
handleFileAnnotation(document, opts, fileAnnotation); | ||
|
||
} else if (object instanceof MapAnnotation) { | ||
MapAnnotation mapAnnotation = (MapAnnotation) object; | ||
handleMapAnnotation(document, opts, mapAnnotation); | ||
} | ||
} | ||
|
||
|
@@ -355,6 +361,31 @@ private void handleFileAnnotation(final Document document, | |
} | ||
} | ||
|
||
/** | ||
* Creates {@link Field} instances for {@link MapAnnotation} named-value | ||
* pair. | ||
* | ||
* @param document | ||
* @param store | ||
* @param index | ||
* @param boost | ||
* @param mapAnnotation | ||
*/ | ||
private void handleMapAnnotation(final Document document, | ||
final LuceneOptions opts, MapAnnotation mapAnnotation) { | ||
logger().error("handling map annotation"); | ||
List<NamedValue> nvs = mapAnnotation.getMapValue(); | ||
if (nvs != null && nvs.size() > 0) { | ||
for (NamedValue nv : nvs) { | ||
if (nv != null) { | ||
logger().error("{}={}", nv.getName(), nv.getValue()); | ||
add(document, nv.getName(), nv.getValue(), opts); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
add(document, "map.key", nv.getName(), opts); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Return the short type name of an {@link Annotation}. If the instance is | ||
* an {@link ome.model.annotations.TextAnnotation} the returned value will | ||
|
There was a problem hiding this comment.
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