More Like This Full Document Query Usage

edit

More Like This Full Document Query Usage

edit

Fluent DSL example

edit
q
.MoreLikeThis(sn => sn
    .Fields(ff => ff
        .Field(f => f.Name)
        .Field(f => f.Description)
    )
    .Like(l => l
        .Document(d => d
            .Document(Project.Instance)
            .Routing(Project.Instance.Name)
        )
        .Text("some long text")
    )
)

Object Initializer syntax example

edit
new MoreLikeThisQuery
{
    Fields = Infer.Fields<Project>(
        f => f.Name,
        f => f.Description),
    Like = new List<Like>
    {
        new LikeDocument<Project>(Project.Instance) { Routing = Project.Instance.Name },
        "some long text"
    }
}

Example json output.

{
  "more_like_this": {
    "fields": [
      "name",
      "description"
    ],
    "like": [
      {
        "_index": "project",
        "doc": {
          "name": "Koch, Collier and Mohr",
          "state": "BellyUp",
          "startedOn": "2015-01-01T00:00:00",
          "lastActivity": "0001-01-01T00:00:00",
          "leadDeveloper": {
            "gender": "Male",
            "id": 0,
            "firstName": "Martijn",
            "lastName": "Laarman"
          },
          "location": {
            "lat": 42.1523,
            "lon": -80.321
          }
        },
        "routing": "Durgan LLC"
      },
      "some long text"
    ]
  }
}