bool_query.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Tencent is pleased to support the open source community by making wwsearch
  3. * available.
  4. *
  5. * Copyright (C) 2018-present Tencent. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  8. * use this file except in compliance with the License. You may obtain a copy of
  9. * the License at
  10. *
  11. * https://opensource.org/licenses/Apache-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "header.h"
  20. #include "query.h"
  21. namespace wwsearch {
  22. class BooleanQuery : public Query {
  23. private:
  24. // one of two will be used.
  25. FieldID field_id_;
  26. kIndexFieldType value_type_;
  27. std::string match_term_;
  28. uint64_t match_numeric_;
  29. public:
  30. BooleanQuery(FieldID field_id, const std::string &term);
  31. BooleanQuery(FieldID field_id, uint64_t value);
  32. BooleanQuery(FieldID field_id, uint32_t value);
  33. virtual ~BooleanQuery();
  34. virtual Weight *CreateWeight(SearchContext *context, bool needs_scores,
  35. double boost) override;
  36. FieldID GetFieldID() { return this->field_id_; }
  37. inline kIndexFieldType ValueType() { return this->value_type_; }
  38. inline bool IsTerm() { return this->value_type_ == kStringIndexField; }
  39. inline std::string &MatchTerm() { return this->match_term_; }
  40. inline uint64_t MatchNumeric() { return this->match_numeric_; }
  41. private:
  42. };
  43. } // namespace wwsearch