Repository: andycasey/ads

Issue:
Bibtex issue
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior
Hello,

I would like to extract the url of the ADS page associated to each entry. I got it from the bibtex entry, but bibtex does always return none when query from the field. More specifically, querying with the following:
papers = list(ads.SearchQuery(author=myname, max_pages=6,fl=['citation_count', 'bibcode', 'title', 'bibtex','year','author']))

does always provide a None for papers[0].bibtex (as well as other entries)

Am I making some error?

Thanks!

Alex



<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (hint: `python -c "import ads; print(ads.__version__)"`)
* Python version (hint: `python -V`)



Discussion:

Patch:
diff --git a/ads/search.py b/ads/search.py
index f1b5205..97727de 100644
--- a/ads/search.py
+++ b/ads/search.py
@@ -399,6 +399,12 @@ class SearchQuery(BaseQuery):
             else:
                 self._query["fl"] = ["id"] + self._query["fl"]
 
+            # remove bibtex and metrics as a safeguard against
+            # https://github.com/andycasey/ads/issues/73
+            for field in ["bibtex", "metrics"]:
+                if field in self._query["fl"]:
+                    self.query["fl"].remove(field)
+
             # Format and add kwarg (key, value) pairs to q
             if kwargs:
                 _ = [u'{}:"{}"'.format(k, v) for k, v in six.iteritems(kwargs)]


Test patch:
diff --git a/ads/tests/test_search.py b/ads/tests/test_search.py
index 3213d42..f27f581 100644
--- a/ads/tests/test_search.py
+++ b/ads/tests/test_search.py
@@ -245,6 +245,10 @@ class TestSearchQuery(unittest.TestCase):
         with six.assertRaisesRegex(self, AssertionError, ".+mutually exclusive.+"):
             SearchQuery(q="start", start=0, cursorMark="*")
 
+        # test that bibtex/metrics is excluded from sq.query['fl']
+        sq = SearchQuery(q="star", fl=["f1", "bibtex", "f2", "metrics", "f3"])
+        self.assertEqual(sq.query['fl'], ["id", "f1", "f2", "f3"])
+
 
 class TestSolrResponse(unittest.TestCase):
     """