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
Sticky category filter #145
Comments
hmm definitely undesirable. Can you try running the service locally and report what the solr calls are (on the log) |
This reminds me that @tudorgroza emailed the same issue and I meant to turn it into a ticket, from Tudor: " the search is for some reason 'stateful'. If I search for 'disease', all subsequent calls will return only disease, even if the category is not specified. If I change the category to 'gene', then again, all subsequent calls will return only genes. " |
http://localhost:5000/api/search/entity/diabetes?rows=1&start=1
The entity returned is http://localhost:5000/api/search/entity/diabetes?rows=1&start=1&category=gene
The entity returned is http://localhost:5000/api/search/entity/diabetes?rows=1&start=1
The entity returned is http://localhost:5000/api/search/entity/diabetes?rows=1&start=1&category=disease
The entity returned is http://localhost:5000/api/search/entity/diabetes?rows=1&start=1
The entity returned is |
Yeah, it looks like the filter query is persisting somehow. |
This is odd, I'm stepping through the code in entitysearch.py: @ns.route('/entity/<term>')
@api.doc(params={'term': 'search string, e.g. shh, parkinson, femur'})
class SearchEntities(Resource):
@api.expect(simple_parser)
#@api.marshal_list_with(search_result)
def get(self, term):
"""
Returns list of matching concepts or entities using lexical search
"""
import pudb; pudb.set_trace()
args = simple_parser.parse_args()
q = GolrSearchQuery(term,
**args)
results = q.exec()
return results PuDB output:
But when stepping into the constructor, PuDB output:
|
ok, this is at the ontobio level
|
I assumed this makes a fresh empty dict each time but apparently not? |
"Python’s default arguments are evaluated once when the function is defined, not each time the function is called (like it is in say, Ruby). This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well." http://docs.python-guide.org/en/latest/writing/gotchas/ I wouldn't have expected that! |
😱 |
Today I Learned! 🐍 |
The category filter is sticky, and I assume others are as well. Maybe data is being re-ordered each time a query is run? For example if you do these queries in this order:
https://api.monarchinitiative.org/api/search/entity/diabetes?rows=1&start=1
This returns a disease
https://api.monarchinitiative.org/api/search/entity/diabetes?rows=1&start=1&category=gene
This appropriately returns a gene.
https://api.monarchinitiative.org/api/search/entity/diabetes?rows=1&start=1
This now returns a gene.
https://api.monarchinitiative.org/api/search/entity/diabetes?rows=1&start=1&category=disease
This returns a disease
https://api.monarchinitiative.org/api/search/entity/diabetes?rows=1&start=1
This now returns a disease.
This seems like a bug to me. The same query parameters should return the same data.
The text was updated successfully, but these errors were encountered: