Skip to content

Commit 7767b8a

Browse files
committed
Fix #2261 add missing Routing option to FieldsLookup
1 parent a86f03f commit 7767b8a

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

src/Nest/QueryDsl/Abstractions/FieldLookup/FieldLookup.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ public interface IFieldLookup
99
{
1010
[JsonProperty("index")]
1111
IndexName Index { get; set; }
12-
12+
1313
[JsonProperty("type")]
1414
TypeName Type { get; set; }
15-
15+
1616
[JsonProperty("id")]
1717
Id Id { get; set; }
18-
18+
1919
[JsonProperty("path")]
2020
Field Path { get; set; }
21+
22+
[JsonProperty("routing")]
23+
string Routing { get; set; }
2124
}
2225

2326
public class FieldLookup : IFieldLookup
@@ -26,6 +29,7 @@ public class FieldLookup : IFieldLookup
2629
public TypeName Type { get; set; }
2730
public Id Id { get; set; }
2831
public Field Path { get; set; }
32+
public string Routing { get; set; }
2933
}
3034

3135
public class FieldLookupDescriptor<T> : DescriptorBase<FieldLookupDescriptor<T>,IFieldLookup>, IFieldLookup
@@ -34,13 +38,15 @@ public class FieldLookupDescriptor<T> : DescriptorBase<FieldLookupDescriptor<T>,
3438
internal Type _ClrType => typeof(T);
3539

3640
IndexName IFieldLookup.Index { get; set; }
37-
41+
3842
TypeName IFieldLookup.Type { get; set; }
39-
43+
4044
Id IFieldLookup.Id { get; set; }
41-
45+
4246
Field IFieldLookup.Path { get; set; }
4347

48+
string IFieldLookup.Routing { get; set; }
49+
4450
public FieldLookupDescriptor()
4551
{
4652
Self.Type = new TypeName { Type = this._ClrType };
@@ -56,5 +62,7 @@ public FieldLookupDescriptor()
5662
public FieldLookupDescriptor<T> Path(Field path) => Assign(a => a.Path = path);
5763

5864
public FieldLookupDescriptor<T> Path(Expression<Func<T, object>> objectPath) => Assign(a => a.Path = objectPath);
65+
66+
public FieldLookupDescriptor<T> Routing(string routing) => Assign(a => a.Routing = routing);
5967
}
60-
}
68+
}

src/Nest/QueryDsl/TermLevel/Terms/TermsQueryJsonConverter.cs

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ private void ReadTerms(ITermsQuery termsQuery, JsonReader reader, JsonSerializer
106106
reader.Read();
107107
ef.Path = reader.Value as string;
108108
break;
109+
case "routing":
110+
reader.Read();
111+
ef.Routing = reader.Value as string;
112+
break;
109113
}
110114
}
111115
termsQuery.TermsLookup = ef;

src/Tests/QueryDsl/TermLevel/Terms/TermsLookupQueryUsageTests.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public TermsLookupQueryUsageTests(ReadOnlyCluster cluster, EndpointUsage usage)
2020
id = 12,
2121
index = "devs",
2222
path = "lastName",
23-
type = "developer"
23+
type = "developer",
24+
routing = "myroutingvalue"
2425
}
2526
}
2627
};
@@ -35,7 +36,8 @@ public TermsLookupQueryUsageTests(ReadOnlyCluster cluster, EndpointUsage usage)
3536
Id = 12,
3637
Index = Index<Developer>(),
3738
Type = Type<Developer>(),
38-
Path = Field<Developer>(p=>p.LastName)
39+
Path = Field<Developer>(p=>p.LastName),
40+
Routing = "myroutingvalue"
3941
}
4042
};
4143

@@ -44,7 +46,11 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
4446
.Name("named_query")
4547
.Boost(1.1)
4648
.Field(p => p.Description)
47-
.TermsLookup<Developer>(e=>e.Path(p=>p.LastName).Id(12))
49+
.TermsLookup<Developer>(e => e
50+
.Path(p => p.LastName)
51+
.Id(12)
52+
.Routing("myroutingvalue")
53+
)
4854
);
4955

5056
protected override ConditionlessWhen ConditionlessWhen => new ConditionlessWhen<ITermsQuery>(a => a.Terms)
@@ -57,4 +63,4 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
5763
q => q.TermsLookup.Path = null,
5864
};
5965
}
60-
}
66+
}

0 commit comments

Comments
 (0)