#Search translations

11 messages · Page 1 of 1 (latest)

thick snow
#

Hello, all my collections have translated fields. And just now, after setting up a big datamodel, I discovered that Directus search does not search translations. Is that true or I have misconfugured something?
I tested it via data studio and via api.
Search via api:
https://db.dl.tlu.ee/items/people/?search=translated
Using filters it works, but that would require massive dev work as there hundres of different fields.
https://db.dl.tlu.ee/items/people/?fields=*.*&filter[_and][0][_and][0][translations][comments][_contains]=translated

thorn starBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

green tree
#

are you restricted to rest? you could use GraphQL but the results wouldn't be "clean" and ready for use

#

if you need rest, you'll need two requests, one for people and one for people_translations

#
fragment PeopleFields on people {
    id
    status
    people_first_name
    people_last_name
}

fragment SearchInPeople on Query {
  found_in_people: people(search: $search) {
    ...PeopleFields
  }
}

fragment SearchInTranslations on Query {
  found_in_translations: people_translations(search: $search) {
    comments
    people_id {
      ...PeopleFields
    }
  }
}

query ($search: String!) {
  ...SearchInPeople
  ...SearchInTranslations
}
#

I couldn't test in your server, for some reaason it's giving me 500 and inspection isn't showing people, but it would be something like that

#

then you can query with {"search": "mysearch"} variables

#

the annoying part is that you still need to define fields you want to return, so 🤷

#

I'd go with two search requests if search is all you need

thick snow
#

thank you for you replay! will check