Skip to content

CommonTermsQuery Parses Incorrectly #1027

Closed
@rlhotovy

Description

@rlhotovy

I tried executing a CommonTermsQuery using the following code:

[Fact]
public void TestQuery()
{
    // method to get a client with correct connection settings
    var client = GetElasticClient();

    var result = client.Search<IndexedTeam>(s => s
        .Query(q => q
            .CommonTerms(t => t
                .OnField("name")
                .Query("Huskers"))));
    Assert.True(result.Hits.Any());
}

and the query returned no results. Using a REST client, I manually sent a post query with the following body to the same instance of Elasticsearch and received several results:

{
  "query" : {
    "common" : {
      "name" : {
        "query" : "Huskers"
      }
    }
  }
}

and I received many results. I believe the issue is in this line. The PropertyName should be "common" so that it matches the Elasticsearch specs. I've cloned the repo locally and tried making this change on my side and it seems to fix the issue, but I wanted to see if anyone else had reported this or noticed it before submitting a pull request. Thanks in advance for you response!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions