Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting not working #15

Open
Grestorn opened this issue Oct 14, 2018 · 0 comments
Open

Highlighting not working #15

Grestorn opened this issue Oct 14, 2018 · 0 comments
Labels
type: bug Something isn't working

Comments

@Grestorn
Copy link

I'm using a simple dfs query with es but for some reason the highlighting doesn't work. What am I doing wrong?

Here's an except the Domain that's searched:

class Story {

    static searchable = {
        only = ['author', 'creationDate', 'publishDate', 'owners', 'id', 'name', 'summary', 'text', 'category']

        author reference:true
        owners reference:true
        category reference:true

        root true
    }
   ...

This is the search call and the highlight settings:

        def highlighter = {
            field 'text'
            field 'summary'
            field 'author.name'
            preTags '<mark>'
            postTags '</mark>'
        }

            def txtSrchResult = Story.search(searchType: 'dfs_query_and_fetch', highlight: highlighter, from: params.offset, size: params.max, sort: params.sort, order: params.order) {
                bool {
                    if(searchTerm?.length() > 0) {
                        must {
                            query_string(query: searchTerm)
                        }
                    }
                    if(! isAdmin) {
                        must {
                            term(deleted: false)
                        }
                        must {
                            term(previouslyApproved: true)
                        }
                    }
                    if(checkids != null) {
                        must {
                            ids(values: checkids)
                        }
                    }
                }
            }

The search itself works fine, I get the results I'm looking for. The "highlight" list is also returned, but it doesn't contain any fragments whatsoever. None of the fields is ever present in the maps, even though the hit is definitely in the text and/or summary.

What am I missing here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants