.netamazon-web-servicessdkamazon-cloudsearch

How to specify search field in AWS CloudSearch (using .net SDK)


I have a domain where I have 2 searchable fields (a literal and a text field), basically Category and Content.

How can I specify a specific field to use in a field? From what I can tell, it will default to search all searchable fields, but that is not what I want (ie, don't want to look for category Cats and get a result from another category just because it includes the word Cat in the content.)

I am using .Net SDK, and I've been going through their documentation, but can't find that section.

Thanks!


Solution

  • After digging a bit more, and that the way to specify a field is using the fields array field.

    When using the .Net SDK, it can be done this way:

    new SearchRequest { 
       Query = query, 
       QueryOptions = @"{""fields"":[""field_name""]}" 
    };
    

    source: https://docs.aws.amazon.com/cloudsearch/latest/developerguide/search-api.html#structured-search-syntax