-
Notifications
You must be signed in to change notification settings - Fork 488
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
Enable metadata_fields parameter on search query. #7942
Conversation
The metadata_fields could take value such as : - metadata_fields=<metadatablock>:* - metadata_fields=<metadatablock>:<field1>&metadata_fields=<metadatablock>:<field2>
return toJsonObject(showRelevance, showEntityIds, showApiUrls, null); | ||
} | ||
|
||
public JsonObject toJsonObject(boolean showRelevance, boolean showEntityIds, boolean showApiUrls, List<String> metadataFields) { | ||
return json(showRelevance, showEntityIds, showApiUrls).build(); | ||
} |
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.
This isn't working because you're passing the metadataFields to the toJsonObject method, but not to the json method at line 414
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.
You are right : I forget this part of code when I report my code from a previous git repository.
The correction is done
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.
Looks good overall. There's one code issue that I added as a single comment and also if you could take a shot at updating the documentation to show examples and output similar to what you put in the issue/PR
Also, please update your branch from develop to make sure there are no conflicts.
Thanks @FNI18300, I'll move this back to the review column so we can take another look. cc: @sekmiller |
Hi @FNI18300 - one more thing that I missed when I moved this back to review. Can you please add some documentation for this, as @sekmiller suggested? It looks like you have a good example above. If you can add this into the documentation, I'll be happy to look at it for grammar/formatting. |
If I could also add, I wouldn't say no to some integration tests, if you feel like writing them @FNI18300 . You could add them to SearchIT.java and if you have any questions, I'm happy to help. |
It's a good suggestion to add documentation about this. |
@FNI18300 Docs are all in the same repo. Here's the source for that Search API page: https://github.com/IQSS/dataverse/blob/develop/doc/sphinx-guides/source/api/search.rst You can find some tips on contributing to documentation here: https://guides.dataverse.org/en/5.5/developers/documentation.html If you run into trouble, just ask. 😄 |
@FNI18300 hi! The following comment from https://groups.google.com/g/dataverse-community/c/l41Cp2KEf9M/m/bAsmR0exAgAJ by @jggautier reminded me to come back to this pull request:
It looks like you added docs back in July (!) in e50df25. Are you ready for this pull request to go back into code review? Thanks! |
Hi, yes i'am ready to go back into code review. I did not found time to add tests (sorry about that) so it will be very kind that my PR will be reviewed "as is"... Do you think it's possible ? Thanks in advance. |
@FNI18300 yep. No problem. I just put it back in review. Thanks for the contribution! When you're ready to go live, please do get in touch to add your installation to the map! 😄 You can just create an issue at https://github.com/IQSS/dataverse-installations/issues |
Hi @FNI18300 - sorry about the delay in getting to this. Can you update from develop? I'll be happy to update the formatting of the docs as well. |
As @kcondon and I have been discussing, I'm not able to reproduce the null pointer exception but he's going to give it a shot. I've been testing with a branch created from this pull request plus the latest from develop merged in: https://github.com/IQSS/dataverse/tree/7942-tweaks I tried with the dataset he mentioned in our Slack conversation as well as the "all fields" dataset (dataset-create-new-all-default-fields.json). (This JSON didn't "just work" to create a dataset, by the way. I got an error and had to take out an item from a controlled vocabulary. Weird.) |
@FNI18300 I should add that if the stacktrace above helps you reproduce the null pointer by all means please go ahead and fix it. |
@pdurbin @FNI18300 I was able to reproduce the issue by pasting the url from the stack trace into my browser: If I put a / before the first * in the url or before the last, I get different responses but neither fails. Is there some logic that counts the occurrence of *? https://dataverse-internal.iq.harvard.edu/api/v1/search?q=\*&type=dataset&metadata_fields=citation:* https://dataverse-internal.iq.harvard.edu/api/v1/search?q=*&type=dataset&metadata_fields=citation:\* and to complete the various combinations: I'm not 100% sure why I was using the various combinations but I think I was following the testing instructions to make a usual call to the api with the new parameter and I saw this in the history of the guides: and the formatting in the guides around the parameter was a bit confusing to me on a quick scan, the example url does show. the format that would work q=* for first occurrence, then citation:* but the sentence below it says, The above example So, I see two issues: 1. what is the correct syntax and does the doc agree, 2. in the case of the incorrect syntax, should it be throwing a null ptr? In discussing with Phil on Friday, he was not able to reproduce the null ptr with the above url on his local build. I was wondering whether dev environments still build and run in debug like they used to and so perhaps automatically initialize all vars as opposed to running in my test env? |
@FNI18300 hi, I've been playing around with your code and I'm not sure why I was unable to reproduce the null pointer before but now I can. I can reproduce the problem both on the 7942-tweaks branch I mentioned (which is just the "develop" branch merged in) and this pull request itself, the tip of which is d02c7f8 as of this writing. This is how I've reproduced it:
I'm including a full stack trace and database dump: Can you please see if you can reproduce (and hopefully fix) this? One thing I observed during my troubleshooting is the error seems to happen on the field
Please let us know if you need more help troubleshooting. Once you fix the bug, please be sure the merge the latest from "develop" into your branch before requesting another review. Thanks! |
Well it seems that the behavior of jsonification has changed. I merge develop into my FNI18300:search_api_metadatafields branch Hoping this times is the right one for merging (this way I could upgrade the project to the new version ;-) |
Hey @FNI18300 - thanks for the updates! We'll take another look. |
@FNI18300 Please refresh this branch from develop since a db change that dropped a column makes this throw exceptions when creating datasets. Thanks! |
Hi, |
The search API is enhanced to add a new parameter called "metadata_fields"
The metadata_fields could take value such as :
or
When the parameter is added in request, the requested fields are returned in a "metadataBlocks" part.
The content of this block is for exemple as follow :
GET /api/search?q=*&metadata_fields=rudi:rudi_summary
Limitation : If the requested field is a a compound one, all the compound properties are returned.
It's is not possible to request a field single from a compound objet.
What this PR does / why we need it:
The PR add a new parameter in search API to customize the returned items.
This way, to display dedicated attributes of a dataset only one request is needed.
Without this enhancement we need to make a first query to get results then for each result a second one to get the requested attributes.
Which issue(s) this PR closes:
Closes #7863
Special notes for your reviewer:
Suggestions on how to test this:
A usual call to the API with the new parameter is sufficient using for exemple a field from geagraphic metadatablock
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No user interface changes.
The added attribute for search API is not mandatory
In SolrSearchResult class when a parameter has been added to methods, the original one is keept.
Is there a release notes update needed for this change?:
no