|
| 1 | +/* Copyright 2010-present MongoDB 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 | +*/ |
| 15 | + |
| 16 | +using MongoDB.Bson; |
| 17 | +using MongoDB.Bson.Serialization.Attributes; |
| 18 | + |
| 19 | +namespace MongoDB.Driver.Search |
| 20 | +{ |
| 21 | + /// <summary> |
| 22 | + /// Represents a result of highlighting. |
| 23 | + /// </summary> |
| 24 | + public sealed class SearchHighlight |
| 25 | + { |
| 26 | + /// <summary> |
| 27 | + /// Gets or sets the document field which returned a match. |
| 28 | + /// </summary> |
| 29 | + [BsonElement("path")] |
| 30 | + public string Path { get; private set; } |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// Gets or sets one or more objects containing the matching text and the surrounding text |
| 34 | + /// (if any). |
| 35 | + /// </summary> |
| 36 | + [BsonElement("texts")] |
| 37 | + public SearchHighlightText[] Texts { get; private set; } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Gets or sets the score assigned to this result. |
| 41 | + /// </summary> |
| 42 | + [BsonElement("score")] |
| 43 | + public double Score { get; private set; } |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Represents the matching text or the surrounding text of a highlighting result. |
| 48 | + /// </summary> |
| 49 | + public sealed class SearchHighlightText |
| 50 | + { |
| 51 | + /// <summary> |
| 52 | + /// Gets or sets the text from the field which returned a match. |
| 53 | + /// </summary> |
| 54 | + [BsonElement("value")] |
| 55 | + public string Value { get; private set; } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Gets or sets the type of text, matching or surrounding. |
| 59 | + /// </summary> |
| 60 | + [BsonElement("type")] |
| 61 | + [BsonRepresentation(BsonType.String)] |
| 62 | + public HighlightTextType Type { get; private set; } |
| 63 | + } |
| 64 | + |
| 65 | + /// <summary> |
| 66 | + /// Represents the type of text in a highlighting result, matching or surrounding. |
| 67 | + /// </summary> |
| 68 | + public enum HighlightTextType |
| 69 | + { |
| 70 | + /// <summary> |
| 71 | + /// Indicates that the text contains a match. |
| 72 | + /// </summary> |
| 73 | + Hit, |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// Indicates that the text contains the text content adjacent to a matching string. |
| 77 | + /// </summary> |
| 78 | + Text |
| 79 | + } |
| 80 | +} |
0 commit comments