2017-08-02 6 views
10

मैं लोचदार खोज और रूबी-ऑन-रेल का उपयोग कर एक मौजूदा प्रोजेक्ट स्थापित करने की कोशिश कर रहा हूं। मैं परियोजना उठकर हालांकि प्रश्नों मेरे लिए विभिन्न त्रुटि संदेश लौट elasticsearch और मेरे सहयोगियों में से कोई भी चल सकते हैं:लोचदार खोज - विकृत क्वेरी (आरओआर)

[400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"[and] query malformed, no start_object after query name","line":1,"col":896}],"type":"parsing_exception","reason":"[and] query malformed, no start_object after query name","line":1,"col":896},"status":400} 

यह स्पष्ट रूप से मुझे ले जाता है यह मेरे सेटअप के साथ क्या करना कुछ विश्वास करने के लिए। मैं उन्हें (2.4) के समान संस्करण स्थापित किया है, फिर भी यहां तक ​​कि सेटअप आदेश है कि परियोजना के साथ आपूर्ति की गई थी:

rake environment elasticsearch:import:all DIR=app/models FORCE=y 

मुझे एक टाइमआउट त्रुटि देता है। मैंने जांच की है और सेवा चल रही है। मेरे सेट अप में क्या गलत हो सकता है, इस बारे में कोई भी मदद की सराहना की जाएगी क्योंकि मैं इस पर 2 दिनों के लिए एक मृत अंत में हूं।

अग्रिम धन्यवाद।

संपादित करें: मुझे नहीं लगता कि के रूप में इस अपने सहयोगियों के लिए काम करता मुद्दा क्वेरी के साथ ही है, लेकिन यह इस प्रकार है:

{: date_range => {: from => Mon, 
    01 Aug 2016 00: 00: 00 UTC + 00: 00, 
    : to => Mon, 
    31 Jul 2017 00: 00: 00 UTC + 00: 00 
    }, : activities_only => nil 
}, @pupils = [# < Pupil id: 1042, first_name: "Mark", last_name: "Mekhaiel", date_of_birth: "2017-03-19", level: 0, group_id: 95, created_at: "2017-07-31 08:59:59", updated_at: "2017-07-31 09:48:27", username: "m.mekhaiel1", picture: 0, color: 0, archived: false, sub_group_id: nil, score: 20, deleted_at: nil > ], @search = # < PupilCreditSearch: 0x007fc961801308 @interval = : month, @page = 1, @per = 25, @pupil_id = [1042], @date_range = {: from => Mon, 
    01 Aug 2016 00: 00: 00 UTC + 00: 00, 
    : to => Mon, 
    31 Jul 2017 00: 00: 00 UTC + 00: 00 
}, @queries = [# < Search::Query: 0x007fc964791bb8 @query = nil, @fields = [], @type = : multi_match, @options = {: fields => [], 
    : type => : cross_fields 
} > ], @filters = [# < Search::Filter: 0x007fc964756db0 @name = : pupil_id, @value = [1042], @type = : terms, @options = {} > ], @aggregations = {: years_created => # < Search::Aggregation: 0x007fc9647a32f0 @type = : date_histogram, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_histogram, 
    : params => {: interval => : year 
    } 
    } > , 
    : months_created => # < Search::Aggregation: 0x007fc9647a30c0 @type = : date_histogram, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_histogram, 
    : params => {: interval => : month 
    } 
    } > , 
    : date_ranges => # < Search::Aggregation: 0x007fc9647a2800 @type = : date_range, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_range, 
    : params => {: keyed => true, 
     : ranges => [{: from => "now/w", 
     : to => "now+1w/w", 
     : key => : this_week 
     }, {: from => "now/M", 
     : to => "now+1M/M", 
     : key => : this_month 
     }, {: from => "now-1w/w", 
     : to => "now-2w/w", 
     : key => : last_week 
     }, {: from => "now-1M/M", 
     : to => "now-2M/M", 
     : key => : last_month 
     }, {: from => "2016-09-01", 
     : to => "2017-08-31", 
     : key => : academic_year 
     }] 
    } 
    } > , 
    : groups => # < Search::Aggregation: 0x007fc9647a2260 @type = : terms, 
    @field = : pupil_id, 
    @options = {: aggs => {: all_dates => # < Search::Aggregation: 0x007fc9647a22d8 @type = : date_histogram, 
     @field = : created_at, 
     @options = {: params => {: interval => : month 
     }, 
     : aggs => {: total_points => # < Search::Aggregation: 0x007fc9647a2440 @type = : sum, 
      @field = : points, 
      @options = {} > , 
      : running_total => # < Search::Aggregation: 0x007fc9647a2350 @type = : cumulative_sum, 
      @field = nil, 
      @options = {: params => {: buckets_path => "total_points" 
      } 
      } > 
     } 
     } > 
    } 
    } > , 
    : options => # < Search::Aggregation: 0x007fc9647a1518 @type = : global, 
    @field = nil, 
    @options = {: aggs => {: filtered => # < Search::Aggregation: 0x007fc9647a1590 @type = : filter, 
     @field = nil, 
     @options = {: params => {: and => [{: range => {: created_at => {: gte => Mon, 
       01 Aug 2016 00: 00: 00 UTC + 00: 00, 
       : lt => Mon, 
       31 Jul 2017 00: 00: 00 UTC + 00: 00 
       } 
      } 
      }, {: terms => {: pupil_id => [1042] 
      } 
      }] 
     }, 
     : aggs => {: categories => # < Search::Aggregation: 0x007fc9647a1b80 @type = : terms, 
      @field = "category", 
      @options = {: ignore => true 
      } > , 
      : topic_ids => # < Search::Aggregation: 0x007fc9647a19a0 @type = : terms, 
      @field = "topic_id", 
      @options = {: ignore => true 
      } > , 
      : learning_objective_ids => # < Search::Aggregation: 0x007fc9647a17c0 @type = : terms, 
      @field = "learning_objective_id", 
      @options = {: ignore => true 
      } > , 
      : completed_activities => # < Search::Aggregation: 0x007fc9647a1608 @type = : terms, 
      @field = : pupil_id, 
      @options = {: aggs => {: activities => # < Search::Aggregation: 0x007fc9647a1680 @type = : filter, 
       @field = nil, 
       @options = {: params => {: and => [{: terms => {: category => [0, 1, 2, 3] 
        } 
        }] 
       } 
       } > 
      } 
      } > 
     } 
     } > 
    } 
    } > 
}, @request = # < Search::Request: 0x007fc964753548 @params = {: query => {: bool => {: must => [{: match_all => {} 
     }], 
     : filter => [{: terms => {: pupil_id => [1042] 
     } 
     }] 
    } 
    }, 
    : aggs => {: years_created => {: date_histogram => {: field => : created_at, 
     : interval => : year 
     } 
    }, 
    : months_created => {: date_histogram => {: field => : created_at, 
     : interval => : month 
     } 
    }, 
    : date_ranges => {: date_range => {: field => : created_at, 
     : keyed => true, 
     : ranges => [{: from => "now/w", 
      : to => "now+1w/w", 
      : key => : this_week 
     }, {: from => "now/M", 
      : to => "now+1M/M", 
      : key => : this_month 
     }, {: from => "now-1w/w", 
      : to => "now-2w/w", 
      : key => : last_week 
     }, {: from => "now-1M/M", 
      : to => "now-2M/M", 
      : key => : last_month 
     }, {: from => "2016-09-01", 
      : to => "2017-08-31", 
      : key => : academic_year 
     }] 
     } 
    }, 
    : groups => {: terms => {: field => : pupil_id 
     }, 
     : aggs => {: all_dates => {: date_histogram => {: field => : created_at, 
      : interval => : month 
      }, 
      : aggs => {: total_points => {: sum => {: field => : points 
       } 
      }, 
      : running_total => {: cumulative_sum => {: buckets_path => "total_points" 
       } 
      } 
      } 
     } 
     } 
    }, 
    : options => {: global => {}, 
     : aggs => {: filtered => {: filter => {: and => [{: range => {: created_at => {: gte => Mon, 
        01 Aug 2016 00: 00: 00 UTC + 00: 00, 
        : lt => Mon, 
        31 Jul 2017 00: 00: 00 UTC + 00: 00 
       } 
       } 
      }, {: terms => {: pupil_id => [1042] 
       } 
      }] 
      }, 
      : aggs => {: categories => {: terms => {: field => "category" 
       } 
      }, 
      : topic_ids => {: terms => {: field => "topic_id" 
       } 
      }, 
      : learning_objective_ids => {: terms => {: field => "learning_objective_id" 
       } 
      }, 
      : completed_activities => {: terms => {: field => : pupil_id 
       }, 
       : aggs => {: activities => {: filter => {: and => [{: terms => {: category => [0, 1, 2, 3] 
         } 
        }] 
        } 
       } 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} >> , @options = # < ReportOptions: 0x007fc96b663258 @search = # < PupilCreditSearch: 0x007fc961801308 @interval = : month, @page = 1, @per = 25, @pupil_id = [1042], @date_range = {: from => Mon, 
    01 Aug 2016 00: 00: 00 UTC + 00: 00, 
    : to => Mon, 
    31 Jul 2017 00: 00: 00 UTC + 00: 00 
}, @queries = [# < Search::Query: 0x007fc964791bb8 @query = nil, @fields = [], @type = : multi_match, @options = {: fields => [], 
    : type => : cross_fields 
} > ], @filters = [# < Search::Filter: 0x007fc964756db0 @name = : pupil_id, @value = [1042], @type = : terms, @options = {} > ], @aggregations = {: years_created => # < Search::Aggregation: 0x007fc9647a32f0 @type = : date_histogram, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_histogram, 
    : params => {: interval => : year 
    } 
    } > , 
    : months_created => # < Search::Aggregation: 0x007fc9647a30c0 @type = : date_histogram, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_histogram, 
    : params => {: interval => : month 
    } 
    } > , 
    : date_ranges => # < Search::Aggregation: 0x007fc9647a2800 @type = : date_range, 
    @field = : created_at, 
    @options = {: field => : created_at, 
    : type => : date_range, 
    : params => {: keyed => true, 
     : ranges => [{: from => "now/w", 
     : to => "now+1w/w", 
     : key => : this_week 
     }, {: from => "now/M", 
     : to => "now+1M/M", 
     : key => : this_month 
     }, {: from => "now-1w/w", 
     : to => "now-2w/w", 
     : key => : last_week 
     }, {: from => "now-1M/M", 
     : to => "now-2M/M", 
     : key => : last_month 
     }, {: from => "2016-09-01", 
     : to => "2017-08-31", 
     : key => : academic_year 
     }] 
    } 
    } > , 
    : groups => # < Search::Aggregation: 0x007fc9647a2260 @type = : terms, 
    @field = : pupil_id, 
    @options = {: aggs => {: all_dates => # < Search::Aggregation: 0x007fc9647a22d8 @type = : date_histogram, 
     @field = : created_at, 
     @options = {: params => {: interval => : month 
     }, 
     : aggs => {: total_points => # < Search::Aggregation: 0x007fc9647a2440 @type = : sum, 
      @field = : points, 
      @options = {} > , 
      : running_total => # < Search::Aggregation: 0x007fc9647a2350 @type = : cumulative_sum, 
      @field = nil, 
      @options = {: params => {: buckets_path => "total_points" 
      } 
      } > 
     } 
     } > 
    } 
    } > , 
    : options => # < Search::Aggregation: 0x007fc9647a1518 @type = : global, 
    @field = nil, 
    @options = {: aggs => {: filtered => # < Search::Aggregation: 0x007fc9647a1590 @type = : filter, 
     @field = nil, 
     @options = {: params => {: and => [{: range => {: created_at => {: gte => Mon, 
       01 Aug 2016 00: 00: 00 UTC + 00: 00, 
       : lt => Mon, 
       31 Jul 2017 00: 00: 00 UTC + 00: 00 
       } 
      } 
      }, {: terms => {: pupil_id => [1042] 
      } 
      }] 
     }, 
     : aggs => {: categories => # < Search::Aggregation: 0x007fc9647a1b80 @type = : terms, 
      @field = "category", 
      @options = {: ignore => true 
      } > , 
      : topic_ids => # < Search::Aggregation: 0x007fc9647a19a0 @type = : terms, 
      @field = "topic_id", 
      @options = {: ignore => true 
      } > , 
      : learning_objective_ids => # < Search::Aggregation: 0x007fc9647a17c0 @type = : terms, 
      @field = "learning_objective_id", 
      @options = {: ignore => true 
      } > , 
      : completed_activities => # < Search::Aggregation: 0x007fc9647a1608 @type = : terms, 
      @field = : pupil_id, 
      @options = {: aggs => {: activities => # < Search::Aggregation: 0x007fc9647a1680 @type = : filter, 
       @field = nil, 
       @options = {: params => {: and => [{: terms => {: category => [0, 1, 2, 3] 
        } 
        }] 
       } 
       } > 
      } 
      } > 
     } 
     } > 
    } 
    } > 
}, @request = # < Search::Request: 0x007fc964753548 @params = {: query => {: bool => {: must => [{: match_all => {} 
     }], 
     : filter => [{: terms => {: pupil_id => [1042] 
     } 
     }] 
    } 
    }, 
    : aggs => {: years_created => {: date_histogram => {: field => : created_at, 
     : interval => : year 
     } 
    }, 
    : months_created => {: date_histogram => {: field => : created_at, 
     : interval => : month 
     } 
    }, 
    : date_ranges => {: date_range => {: field => : created_at, 
     : keyed => true, 
     : ranges => [{: from => "now/w", 
      : to => "now+1w/w", 
      : key => : this_week 
     }, {: from => "now/M", 
      : to => "now+1M/M", 
      : key => : this_month 
     }, {: from => "now-1w/w", 
      : to => "now-2w/w", 
      : key => : last_week 
     }, {: from => "now-1M/M", 
      : to => "now-2M/M", 
      : key => : last_month 
     }, {: from => "2016-09-01", 
      : to => "2017-08-31", 
      : key => : academic_year 
     }] 
     } 
    }, 
    : groups => {: terms => {: field => : pupil_id 
     }, 
     : aggs => {: all_dates => {: date_histogram => {: field => : created_at, 
      : interval => : month 
      }, 
      : aggs => {: total_points => {: sum => {: field => : points 
       } 
      }, 
      : running_total => {: cumulative_sum => {: buckets_path => "total_points" 
       } 
      } 
      } 
     } 
     } 
    }, 
    : options => {: global => {}, 
     : aggs => {: filtered => {: filter => {: and => [{: range => {: created_at => {: gte => Mon, 
        01 Aug 2016 00: 00: 00 UTC + 00: 00, 
        : lt => Mon, 
        31 Jul 2017 00: 00: 00 UTC + 00: 00 
       } 
       } 
      }, {: terms => {: pupil_id => [1042] 
       } 
      }] 
      }, 
      : aggs => {: categories => {: terms => {: field => "category" 
       } 
      }, 
      : topic_ids => {: terms => {: field => "topic_id" 
       } 
      }, 
      : learning_objective_ids => {: terms => {: field => "learning_objective_id" 
       } 
      }, 
      : completed_activities => {: terms => {: field => : pupil_id 
       }, 
       : aggs => {: activities => {: filter => {: and => [{: terms => {: category => [0, 1, 2, 3] 
         } 
        }] 
        } 
       } 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

क्या आप [elasticsearch-ruby ] (https://github.com/elastic/elasticsearch-ruby) मणि का उपयोग करते हैं? –

+2

क्या आप यहां क्वेरी पोस्ट कर सकते हैं जिसे आप भेज रहे हैं? – sourabh1024

+0

आपकी क्वेरी और नमूना दस्तावेज पोस्ट करने के लिए आप जिस क्वेरी और आउटपुट को प्राप्त करने का प्रयास कर रहे हैं उसे पोस्ट करने में आपकी मदद कर रहे हैं – user93

उत्तर

0

समस्या एकत्रित, अर्थात् से एक के साथ है:

:filter => { :and => [...] }

... जो, कि आप वास्तव में elasticsearch 5 और नहीं 2.4 चल रहा है हो सकता है, आपकी मशीन पर इस निष्कर्ष पर मुझे ले जाता है, क्योंकि इस वाक्य रचना के पक्ष में संस्करण 5 में गिरा दिया गया:

:filter => { :bool => { :must: [...] } }

(या वास्तविक होस्ट/पोर्ट अपने अनुप्रयोग से जुड़ रहा है) curl localhost:9200 साथ elasticsearch संस्करण को सत्यापित करें।

संबंधित मुद्दे