field.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2014 Couchbase, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package document
  15. import (
  16. "github.com/blevesearch/bleve/analysis"
  17. )
  18. type Field interface {
  19. // Name returns the path of the field from the root DocumentMapping.
  20. // A root field path is "field", a subdocument field is "parent.field".
  21. Name() string
  22. // ArrayPositions returns the intermediate document and field indices
  23. // required to resolve the field value in the document. For example, if the
  24. // field path is "doc1.doc2.field" where doc1 and doc2 are slices or
  25. // arrays, ArrayPositions returns 2 indices used to resolve "doc2" value in
  26. // "doc1", then "field" in "doc2".
  27. ArrayPositions() []uint64
  28. Options() IndexingOptions
  29. Analyze() (int, analysis.TokenFrequencies)
  30. Value() []byte
  31. // NumPlainTextBytes should return the number of plain text bytes
  32. // that this field represents - this is a common metric for tracking
  33. // the rate of indexing
  34. NumPlainTextBytes() uint64
  35. Size() int
  36. }