<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: priteshbaviskar</title>
    <description>The latest articles on DEV Community by priteshbaviskar (@priteshbaviskar).</description>
    <link>https://dev.to/priteshbaviskar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F437393%2F26d0de3f-7430-46f1-8214-3cd4278aba0c.png</url>
      <title>DEV Community: priteshbaviskar</title>
      <link>https://dev.to/priteshbaviskar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priteshbaviskar"/>
    <language>en</language>
    <item>
      <title>Spring Boot(v.2.3.1 and above) + Elasticsearch</title>
      <dc:creator>priteshbaviskar</dc:creator>
      <pubDate>Wed, 16 Feb 2022 09:28:24 +0000</pubDate>
      <link>https://dev.to/priteshbaviskar/spring-bootv231-and-above-elasticsearch-l25</link>
      <guid>https://dev.to/priteshbaviskar/spring-bootv231-and-above-elasticsearch-l25</guid>
      <description>&lt;p&gt;If you are like me who have spent endless hours trying to connect ElasticSearch with Spring Boot with no luck yet, this is for you!&lt;/p&gt;

&lt;p&gt;There are probably hundreds of tutorials out there but none of them explicitly describe on how to configure a Spring Boot (versions 2.3.1 and above) with Elasticsearch.&lt;/p&gt;

&lt;p&gt;Both, Elasticsearch and Spring Boot have been constantly rolling out newer versions, better than the previous ones at the same time making it painstakingly difficult to manage compatibility issues.&lt;/p&gt;

&lt;p&gt;Most of the tutorials and examples on Stackoverflow and the Internet are based upon an older version of SB wherein it is necessary to define a RestHighLevelClient&lt;/p&gt;

&lt;p&gt;Even the official documentation of Elastic recommends using a RestHighLevelClient with Spring.&lt;/p&gt;

&lt;p&gt;All of the above makes sense with a older version of Spring Boot or if you are using a Spring web application with a separate configuration for Spring Data Elastic.&lt;/p&gt;

&lt;p&gt;Since v2.3.1, in order to configure Elasticsearch with your SpringBoot application, all you have to do is add the following dependency-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-boot-starter-data-elasticsearch&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it. Spring Boot provides a default ElasticsearchRestTemplate. ElasticsearchRestTemplate is part of release 4 of Spring Data ES which provides out of box support for CRUD operations on ES.&lt;/p&gt;

&lt;p&gt;Example to add documents to an index named products —&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
IndexQuery indexQuery = new IndexQueryBuilder()
        .withId(productDocument.getProductID().toString())
        .withObject(productDocument)
        .build();
return elasticsearchRestTemplate.index(indexQuery, IndexCoordinates.of("products"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s all!&lt;/p&gt;

&lt;p&gt;There’s no need of creating another RestHighLevelClient or managing any other version specific dependencies to make this work.&lt;/p&gt;

&lt;p&gt;More information on ElasticsearchRestTemplate can be found on the Spring official ES doc &lt;a href="https://docs.spring.io/spring-data/elasticsearch/docs/current/api/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplate.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Add JSON LD schema with NextJS in these 2 steps.</title>
      <dc:creator>priteshbaviskar</dc:creator>
      <pubDate>Mon, 14 Feb 2022 11:55:35 +0000</pubDate>
      <link>https://dev.to/priteshbaviskar/add-json-ld-schema-with-nextjs-in-these-3-steps-49ja</link>
      <guid>https://dev.to/priteshbaviskar/add-json-ld-schema-with-nextjs-in-these-3-steps-49ja</guid>
      <description>&lt;p&gt;We recently upgraded the NextJS version for our CMS portal at &lt;a href="https://storeplum.in"&gt;Storeplum&lt;/a&gt; and decided to add structured data for each page. &lt;/p&gt;

&lt;p&gt;Found a npm library but it was kind of outdated. After a lot of searching, I found that the solution was fairly straightforward. &lt;/p&gt;

&lt;p&gt;All I did was added the schema definition into a script tag as below-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get your schema definition -
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let schema = {
  "@context": "https://schema.org",
  "@type": "Article",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "example.com/articleURL"
  },
  "headline": "Article title",
  "image": [
    spContent.metaData.twitterCard
   ],
  "datePublished": spContent.created_at,
  "dateModified": spContent.metaData.articleModifiedTime,
  "author": [{
      "@type": "Person",
      "name": "Json Bourne",
      "url": "example.com/jbourne"
    }],
  "publisher": {
      "@type": "Organization",
      "name": "abc",
      "logo": {
        "@type": "ImageObject",
        "url": "example.com/image"
      }
    },
  "description": "some description"

};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Put your data string inside a script tag as below
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;script 
            type='application/ld+json'
            dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all! You can verify your changes once you deploy using &lt;a href="https://search.google.com/test/rich-results"&gt;this&lt;/a&gt; tool by Google.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
