Code Monkey home page Code Monkey logo

Comments (3)

grtjn avatar grtjn commented on August 18, 2024

Attached a proposed rewrite of the function in which type is preserved as a metadata property, and values are pushed into a values array property:

  // Rewrite the data.results part of the response from /v1/search so that the metadata section in each is easier
  // to work with.
  function rewriteResults(results) {
    var rewritten = [];
    var revised = {};
    var metadata;

    angular.forEach(results, function(result, i) {
      revised = {};

      angular.forEach(result, function(property, prop) {
        if (prop === 'metadata') {
          metadata = {};

          angular.forEach(property, function(field, j) {
            angular.forEach(field, function(value, key) {
              if (key !== 'metadata-type') {
                if (metadata[key] === undefined) {
                  metadata[key] = { name: key, 'metadata-type': field['metadata-type'] };
                }
                if (metadata[key].values) {
                  metadata[key].values.push(value);
                } else {
                  metadata[key].values = [ value ];
                }
              }
            });
          });

          revised.metadata = metadata;
        } else {
          revised[prop] = result[prop];
        }
      });

      rewritten.push(revised);
    });

    return rewritten;
  }

from slush-marklogic-node.

joemfb avatar joemfb commented on August 18, 2024

fixed in #49

from slush-marklogic-node.

grtjn avatar grtjn commented on August 18, 2024

Superseded by ml-search-ng in which this has been fixed.

from slush-marklogic-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.