~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/search.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2014-04-14 20:07:28 UTC
  • mfrom: (500.1.9 es-missing-data)
  • Revision ID: tarmac-20140414200728-ew38mtkdrsuprcff
Do not index charm annotations in bundles.

Charms in bundles have "annotations" which include information relating to the
widget layout when placed in the GUI ('gui-x' and 'gui-y').  This information
is ancilliary to the actual bundle and should not be searchable.

The presence of such data has also caused operational problems.  In
production, some bundles are not being indexed due to parsing errors of the x
and y coordinates.

An example failure is shown here:
2014-04-11 19:12:30,096 DEBUG [pyelasticsearch][MainThread] got response {u'items': [{u'index': {u'_type': u'bundle', u'_id': u'~charmers/muletrain/wiki', u'error': u'MapperParsingException[failed to parse [data.data.services.mediawiki.annotations.gui-y]]; nested: NumberFormatException[For input string: "-117.5"]; ', u'_index': u'charms-78512'}}], u'took': 4}

Unfortunately, this ingestion failure cannot be reproduced on staging or
locally.  Further, it appears pyelasticsearch is not returning an error in
this situation but is instead silently failing to index the bundle.

To QA the branch, in one window run 'make run'.  In another, ingest some
bundles:

% bin/ingest-queued --prefix="~charmers/charms/bundles"

Afterwards, go to 'localhost:2464' in your browser.  Search for 'bundles' and
see the ones that got ingested.  Next search for 'gui-x' and see no results.

https://codereview.appspot.com/87710043/

R=jcsackett.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
771
771
            be used.
772
772
        :param charms: A list of charms.  If None, the charms in the current
773
773
            index will be used.
 
774
        :param bundles: A list of bundles.  If None, the bundles in the current
 
775
            index will be used.
774
776
        :return: The ElasticSearchClient for the supplied mapping.
775
777
        """
776
778
        with self.replacement(name) as copy:
777
779
            if charms is None:
778
780
                try:
779
781
                    result = self.api_search(valid_only=False, doctype=CHARM)
780
 
                    charms = [r['data'] for r in result]
 
782
                    charms = [charm['data'] for charm in result]
781
783
                except IndexMissing:
782
784
                    charms = []
783
785
            copy.index_charms(charms)
785
787
            if bundles is None:
786
788
                try:
787
789
                    result = self.api_search(valid_only=False, doctype=BUNDLE)
788
 
                    bundles = [r['data'] for r in result]
 
790
                    bundles = [bundle['data'] for bundle in result]
789
791
                except IndexMissing:
790
792
                    bundles = []
791
793
            copy.index_bundles(bundles)
830
832
    If the index isn't present, a new index is created and aliased to it.
831
833
    If the index is present and compatible, it is simply upgraded.
832
834
    if the index is present and incompatible, its contents are reindexed.
 
835
 
 
836
    :index_client: The client to use.
 
837
    :force_reindex: Do not test for compatability, just do the indexing.  This
 
838
      parameter is for testing purposes only.
833
839
    """
834
840
    actual_client = index_client
835
841
    try:
852
858
 
853
859
 
854
860
def update_main():
855
 
    """A main function for the es-update script."""
 
861
    """A main function for the es-update script.
 
862
 
 
863
    The purpose of this script is to create an initial index if starting from
 
864
    scratch or update the mapping if it has changed.
 
865
    """
856
866
    update(ElasticSearchClient.from_settings(get_ini()))