// Generated by CoffeeScript 2.3.2
(function() {
  var Attribute, Fulltext;

  Attribute = require('./attribute');

  module.exports = Fulltext = class Fulltext extends Attribute {
    constructor(options) {
      var ref, ref1;
      super(options);
      this.boost = options.boost;
      this.query = (ref = options.query) != null ? ref : true;
      this.includeSubfields = (ref1 = options.includeSubfields) != null ? ref1 : false;
      if (!this.query) {
        this.filter = function(paramString) {
          return {
            match_phrase_prefix: {
              [`${options.field}`]: {
                query: paramString,
                zero_terms_query: "all"
              }
            }
          };
        };
      }
    }

    highlight() {
      var ref;
      return (ref = this._options.highlight) != null ? ref : {};
    }

    highlightSubfields() {
      var _, obj, ref, subField;
      switch (false) {
        case this._options.highlightSubfields == null:
          return this._options.highlightSubfields;
        case this.includeSubfields !== true:
          return {
            [`${this.field}.*`]: {}
          };
        case typeof this.includeSubfields !== "object":
          obj = {};
          ref = this.includeSubfields;
          for (subField in ref) {
            _ = ref[subField];
            obj[subField] = {};
          }
          return obj;
        default:
          return {};
      }
    }

  };

}).call(this);
