How to get the ACF field where the search pattern was found into

  • mdruilhe
    Participant
    3 years, 1 month ago #25291

    Hello,

    I have a custom post type with the following structure :

    
    - titre
    - date
    - ../..
    - presentations (repeater)
      - titre
      - resume
      - auteur
      - fichier
      - ../..
    

    I would like to get the ACF field into which the search was found.
    Currently I get the post content, with the post_excerpt set to the extract containing the term found, but the content is not properly highlighted and it is not easy for the user to find where the term was found.
    I can loop other the ACF structure, then check each field / subfield to find the pattern, but I also could do it w/o WPSOLR.
    Is there a way (hook, filter) to do so ?
    Thanks in advance for your help.
    Marc

    mdruilhe
    Participant
    3 years, 1 month ago #25297

    Also, unless I miss some thing, it seems that the post excerpt doesn’t limit to the subfield contents but returns a string across several subfields.
    eg: I have the following contents:

    
    Lieu: Paris
    Date: 9 mars 2021
    Conferences:
      Titre : Test recherche sous-champ ACF
      Résumé: Ceci est un test de wpsolr avec ACF
    

    A search on “ACF” returns the following excerpt :

    . 1615342860000. Paris. Ceci est un test de wpsolr avec ACF . Test recherche sous-champ ACF...

    I would expect : “Ceci est un test de wpsolr avec ACF”

    Thanks in advance for your help
    Marc

    wpsolr
    Keymaster
    3 years, 1 month ago #25301

    Yes, by default search is performed on a concatenation of all indexed fields (if you chose “Index custom fields and categories” in screen 2.2).

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.