Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion docs/client-concepts/high-level/mapping/fluent-mapping.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ var createIndexResponse = _client.Indices.Create("myindex", c => c
"birthDayOfWeek": {
"type": "keyword",
"script": {
"lang": "painless",
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
}
}
Expand All @@ -427,3 +426,38 @@ createIndexResponse = _client.Indices.Create("myindex", c => c
);
----

One may also include and use parameters in the script.

[source,csharp]
----
createIndexResponse = _client.Indices.Create("myindex", c => c
.Map<Company>(m => m
.RuntimeFields(rtf => rtf
.RuntimeField("birthDayOfWeek", FieldType.Keyword, f => f
.Script(s => s
.Source("emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT) + params.suffix)")
.Params(p => p.Add("suffix", " with a suffix."))
)))
)
);
----

[source,javascript]
----
{
"mappings": {
"runtime": {
"birthDayOfWeek": {
"type": "keyword",
"script": {
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT) + params.suffix)",
"params": {
"suffix": " with a suffix."
}
}
}
}
}
}
----

4 changes: 4 additions & 0 deletions docs/query-dsl.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ NEST exposes all of the full text queries available in Elasticsearch

:anchor-list: query-dsl/full-text

* <<combined-fields-usage,Combined Fields Usage>>

* <<common-terms-usage,Common Terms Usage>>

* <<intervals-usage,Intervals Usage>>
Expand All @@ -67,6 +69,8 @@ See the Elasticsearch documentation on {ref_current}/full-text-queries.html[Full

:includes-from-dirs: query-dsl/full-text

include::query-dsl/full-text/combined-fields/combined-fields-usage.asciidoc[]

include::query-dsl/full-text/common-terms/common-terms-usage.asciidoc[]

include::query-dsl/full-text/intervals/intervals-usage.asciidoc[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/master

:github: https://github.com/elastic/elasticsearch-net

:nuget: https://www.nuget.org/packages

////
IMPORTANT NOTE
==============
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/QueryDsl/FullText/CombinedFields/CombinedFieldsUsageTests.cs.
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
////

[[combined-fields-usage]]
=== Combined Fields Usage

The `combined_fields` query supports searching multiple text fields as if their contents had been indexed into one combined field. It takes a
term-centric view of the query: first it analyzes the query string into individual terms, then looks for each term in any of the fields.

See the Elasticsearch documentation on {ref_current}/query-dsl-combined-fields-query.html[combined fields query] for more details.

==== Fluent DSL example

[source,csharp]
----
q
.CombinedFields(c => c
.Fields(f => f.Field(p => p.Description).Field("myOtherField"))
.Query("hello world")
.Boost(1.1)
.Operator(Operator.Or)
.MinimumShouldMatch("2")
.ZeroTermsQuery(ZeroTermsQuery.All)
.Name("combined_fields")
.AutoGenerateSynonymsPhraseQuery(false)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new CombinedFieldsQuery
{
Fields = Field<Project>(p => p.Description).And("myOtherField"),
Query = "hello world",
Boost = 1.1,
Operator = Operator.Or,
MinimumShouldMatch = "2",
ZeroTermsQuery = ZeroTermsQuery.All,
Name = "combined_fields",
AutoGenerateSynonymsPhraseQuery = false
}
----

[source,javascript]
.Example json output
----
{
"combined_fields": {
"_name": "combined_fields",
"boost": 1.1,
"query": "hello world",
"minimum_should_match": "2",
"operator": "or",
"fields": [
"description",
"myOtherField"
],
"zero_terms_query": "all",
"auto_generate_synonyms_phrase_query": false
}
}
----

[float]
=== Combined fields with boost usage

==== Fluent DSL example

[source,csharp]
----
q
.CombinedFields(c => c
.Fields(Field<Project>(p => p.Description, 2.2).And("myOtherField^1.2"))
.Query("hello world")
)
----

==== Object Initializer syntax example

[source,csharp]
----
new CombinedFieldsQuery
{
Fields = Field<Project>(p => p.Description, 2.2).And("myOtherField^1.2"),
Query = "hello world",
}
----

[source,javascript]
.Example json output
----
{
"combined_fields": {
"query": "hello world",
"fields": [
"description^2.2",
"myOtherField^1.2"
]
}
}
----

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ q
.BottomRight(-34, 34)
)
.ValidationMethod(GeoValidationMethod.Strict)
.Type(GeoExecution.Indexed)
)
----

Expand All @@ -47,7 +46,6 @@ new GeoBoundingBoxQuery
TopLeft = new GeoLocation(34, -34),
BottomRight = new GeoLocation(-34, 34),
},
Type = GeoExecution.Indexed,
ValidationMethod = GeoValidationMethod.Strict
}
----
Expand All @@ -57,7 +55,6 @@ new GeoBoundingBoxQuery
----
{
"geo_bounding_box": {
"type": "indexed",
"validation_method": "strict",
"_name": "named_query",
"boost": 1.1,
Expand Down Expand Up @@ -88,7 +85,6 @@ q
.WellKnownText("BBOX (-34, 34, 34, -34)")
)
.ValidationMethod(GeoValidationMethod.Strict)
.Type(GeoExecution.Indexed)
)
----

Expand All @@ -105,7 +101,6 @@ new GeoBoundingBoxQuery
{
WellKnownText = "BBOX (-34, 34, 34, -34)"
},
Type = GeoExecution.Indexed,
ValidationMethod = GeoValidationMethod.Strict
}
----
Expand All @@ -115,7 +110,6 @@ new GeoBoundingBoxQuery
----
{
"geo_bounding_box": {
"type": "indexed",
"validation_method": "strict",
"_name": "named_query",
"boost": 1.1,
Expand Down
4 changes: 2 additions & 2 deletions docs/search/request/search-after-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ s => s

[source,csharp]
----
new SearchRequest<Project>
new SearchRequest<Project>()
{
Sort = new List<ISort>
{
Expand Down Expand Up @@ -92,7 +92,7 @@ s => s

[source,csharp]
----
new SearchRequest<Project>
new SearchRequest<Project>()
{
Sort = new List<ISort>
{
Expand Down
3 changes: 1 addition & 2 deletions docs/search/searching-runtime-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ which yields the following query JSON
"runtime_mappings": {
"search_runtime_field": {
"script": {
"lang": "painless",
"source": "if (doc['type'].size() != 0) {emit(doc['type'].value.toUpperCase())}"
},
"type": "keyword"
Expand All @@ -139,7 +138,7 @@ var searchRequest = new SearchRequest<Project>
{ "search_runtime_field", new RuntimeField
{
Type = FieldType.Keyword,
Script = new PainlessScript("if (doc['type'].size() != 0) {emit(doc['type'].value.toUpperCase())}")
Script = new InlineScript("if (doc['type'].size() != 0) {emit(doc['type'].value.toUpperCase())}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Accept(IMappingVisitor visitor)

public class IndexMappings
{
[Obsolete("Mapping are no longer grouped by type, this indexer is ignored and simply returns Mapppings")]
[Obsolete("Mapping are no longer grouped by type, this indexer is ignored and simply returns Mappings")]
public TypeMapping this[string type] => Mappings;

[DataMember(Name = "mappings")]
Expand Down
Loading