AppSearch feature request. Filter only fields

I understand nested fields like arrays would be problematic for AppSearch, but would it be possible to support arrays that are unsearchable and can only be used to filter results? In ES you can filter an array with an array. For instance you could have a document that belongs to certain groups and users that belong to certain groups.

That sounds interesting. I'm having trouble visualizing this, could you possibly post an example of a document structure that you had in mind?

I am having probably very similar issue.

Let's say we have an engine with cats and dogs (they are distinguished by an attribute "type" which either equals to "cat" or "dog"). Each animal has also its name.
And I want to send a single query to the engine with a pet-name and want to get 5 best matching dogs and 5 best matching cats with the most similar names to my query.

Is it actually possible? Or would it be better to send separate queries or create two separate engines? I am mainly concerned about the performance aspect.

Thank you very much in advance!

To visualize my use case, If you have articles that belong to certain groups(could be one or many) and you have users that belong to certain groups(could be one or many) you need to filter articles based on the users groups. In Elasticsearch you can simply have a list of groups on each article and then filter with a list of groups the user belongs to. However, this is much harder to accomplish in AppSearch. I have not looked into how AppSearch structures its indexes, but I assume nested data structure create to many complications for text search, but if nested data structures could be used for filtering only and not searching it would simplify this case in AppSearch.

ES example

{
  "query": {
    "bool" : {
      "must" : {
        "terms" : { "groups" : [...user_groups] }
      }
  }
}

I believe you can achieve what you want by grouping results by the type. Grouping allows you to set a number value to be returned in each group. AppSearch Grouping, 5 cats and 5 dogs in this case. You can then combine then in your app ordered by score. This is the only way I am aware of to accomplish what you want. You will need to request the score be returned in your response.

Hey @mbrimmer83,

So you have articles that looks something like this?

[
  {
    id: '1',
    name: 'Article 1',
    groups: ['1', '3', '9', '10']
  },
  {
    id: '2',
    name: 'Article 1',
    groups: ['8', '3', '22']
  }

If that's the case, then you should be able to filter an array of groups:

https://www.elastic.co/guide/en/app-search/7.8/filters.html

{
  "query": "",
  "filters" : {
    "groups": [ "1", "3" ]
  }
}

Let me know if I misunderstood!

Jason

Hey @jasonStoltz, I would like to have articles structured like you have them in AppSearch, but I can't because AppSearch doesn't support having an array data field to filter on. That is the feature request I am asking for. Currently, I have only two options to achieve this: 1) duplicate articles for each group or 2) query a list of articles the user can see and filter by those ids. Neither is solution is great.

Hey @mbrimmer83,

Well then you'll be pleased to know that App Search does support arrays! So the example I posted should work.

Jason

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.