def from_criteria(criteria)
      queries = []

      criteria.each do |k, v|
        name, operator, index_type, value = nil
        query_options = {}

        if (v.is_a?(Hash))
          name = k.to_s
          query_options.merge!(v.delete(:options) || {})

          sub_queries = []
          v.each do |kk, vv|
            operator = kk.to_s.gsub('$', '').upcase || "EQ"
            if @operators.include?(operator)
              value = vv
              value = value.to_s if value.is_a?(MarkLogic::ObjectId)
              sub_queries << build_query(name, operator, value, query_options)
            elsif value.is_a?(Hash)
              child_queries = value.map do |kk, vv|
                build_query(kk, vv, query_options)
              end
              sub_queries << Queries::ContainerQuery.new(name, Queries::AndQuery.new(child_queries))
            end
          end

          if sub_queries.length > 1
            queries << Queries::AndQuery.new(sub_queries)
          elsif sub_queries.length == 1
            queries << sub_queries[0]
          end
        else
          name = k.to_s
          value = v
          operator = "EQ"
          queries << build_query(name, operator, value, query_options)
        end
      end

      if queries.length > 1
        MarkLogic::Queries::AndQuery.new(*queries)
      elsif queries.length == 1
        queries[0]
      end
    end
def from_criteria(criteria)
      queries = []

      criteria.each do |k, v|
        name, operator, index_type, value = nil
        query_options = {}

        if (v.is_a?(Hash))
          name = k.to_s
          query_options.merge!(v.delete(:options) || {})

          sub_queries = []
          v.each do |kk, vv|
            operator = kk.to_s.gsub('$', '').upcase || "EQ"
            if @operators.include?(operator)
              value = vv
              value = value.to_s if value.is_a?(MarkLogic::ObjectId)
              sub_queries << build_query(name, operator, value, query_options)
            elsif value.is_a?(Hash)
              child_queries = value.map do |kk, vv|
                build_query(kk, vv, query_options)
              end
              sub_queries << Queries::ContainerQuery.new(name, Queries::AndQuery.new(child_queries))
            end
          end

          if sub_queries.length > 1
            queries << Queries::AndQuery.new(sub_queries)
          elsif sub_queries.length == 1
            queries << sub_queries[0]
          end
        else
          name = k.to_s
          value = v
          operator = "EQ"
          queries << build_query(name, operator, value, query_options)
        end
      end

      if queries.length > 1
        MarkLogic::Queries::AndQuery.new(*queries)
      elsif queries.length == 1
        queries[0]
      end
    end
Builds a MarkLogic Query from Mongo Style Criteria

 @param [Hash] criteria The Criteria to use when searching

 @example Build a query from criteria

    # Query on age == 3
    collection.from_criteria({ 'age' => { '$eq' =>  3  } })

    # Query on age < 3
    collection.from_criteria({ 'age' => { '$lt' =>  3  } })

    # Query on age <= 3
    collection.from_criteria({ 'age' => { '$le' =>  3  } })

    # Query on age > 3
    collection.from_criteria({ 'age' => { '$gt' =>  3  } })

    # Query on age >= 3
    collection.from_criteria({ 'age' => { '$ge' =>  3  } })

    # Query on age != 3
    collection.from_criteria({ 'age' => { '$ne' =>  3  } })

 @since 0.0.1