question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Open Graph Meta for crawling and JSON results

See original GitHub issue

Hello,

I try to add Open Graph Meta inside my JSON results, my goal is to build a custom page based on the FESS JSON search to display the results with these fields by results :

  • Title (based on <meta property=“og:title”)
  • Description (based on <meta property=“og:description”)
  • Thumbnail (based on <meta property=“og:image”)
  • Url (based on <meta property=“og:url”)

I try to add it on doc.json like this :

"og:title": { "type": "keyword" }, "og:description": { "type": "keyword" }, "og:image": { "type": "keyword" }, "og:url": { "type": "keyword" }

And add it inside fess_config.properties :

query.additional.response.fields=og:title,og:description,og:image,og:url query.additional.search.fields=og:title,og:description,og:image,og:url

On the extractor side : <!-- Open Graph --> <postConstruct name="addFieldRule"> <arg>"og:title"</arg> <arg>"//META[@name='og:title']/@content"</arg> </postConstruct> <postConstruct name="addFieldRule"> <arg>"og:description"</arg> <arg>"//META[@name='og:description']/@content"</arg> </postConstruct> <postConstruct name="addFieldRule"> <arg>"og:image"</arg> <arg>"//META[@name='og:image']/@content"</arg> </postConstruct> <postConstruct name="addFieldRule"> <arg>"og:url"</arg> <arg>"//META[@name='og:url']/@content"</arg> </postConstruct>

I restart the web crawling, but my json response is steel the same http://localhost:8080/json?q=flying :

[ { "filetype": "...", "title": "...", "content_title": "...", "digest": "...", "host": "...", "content_length": "351497", "timestamp": "2018-05-02T08:51:08.722Z", "url_link": "...", "created": "2018-05-02T08:51:08.722Z", "site_path": "...", "doc_id": "cbbba5547af04318aadec0d2de49e2a5", "url": "https://...", "content_description": "...", "site": "...", "filename": "...", "boost": "1.0", "mimetype": "text/html" } ] No attribute og:*

Any idea? Thanks by advance!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
inycommented, May 3, 2018

Hello there,

Could you try it this way?

<postConstruct name="addFieldRule">
    <arg>"og_title"</arg>
    <arg>"//META[@ property =\"og:title\"]/@content"</arg>
 </postConstruct>

query.additional.api.response.fields=og_title

You can edit other “og” tags like this

1reaction
marevolcommented, May 3, 2018

To add a custom field(ex. og_title), steps is:

  1. Add a field name to query.additional.response.fields in fess_config.properites query.additional.api.response.fields is for API response, such as JSON.
  2. Start Fess
  3. Add a field type to doc.json ex. {"og_title": { "type": "keyword" }}
  4. Start reindexing with Update Aliases
  5. Create Crawling Config with Config Parameters ex. field.xpath.og_title=//META[@property='og:title']/@content
  6. Start Crawler
  7. Edit JSP files(ex. searchResult.jsp)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webmasters - Sharing - Meta for Developers - Facebook
Without these Open Graph tags, the Facebook Crawler uses internal heuristics to make a best guess about the title, description, and preview image...
Read more >
javascript - How to set dynamic Meta Tags and Open Graph ...
I have a polymer node site that I've been working on and can't figure out how to include dynamic meta tags and Open...
Read more >
Open Graph Meta Tags: Everything You Need to Know - Ahrefs
Open Graph meta tags are snippets of code that control how URLs are displayed when shared on social media. Learn how to set...
Read more >
Adding dynamic meta tags to a React app without SSR
If you want your app to stand out in search results and on social media and messaging platforms, you need to set up...
Read more >
The Open Graph protocol
The Open Graph protocol enables any web page to become a rich object in a social graph.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found