<?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: Utsav Upadhyay</title>
    <description>The latest articles on DEV Community by Utsav Upadhyay (@utsaw).</description>
    <link>https://dev.to/utsaw</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%2F1001799%2F0e69dedf-1c71-486c-be7d-68d44a8a820b.jpeg</url>
      <title>DEV Community: Utsav Upadhyay</title>
      <link>https://dev.to/utsaw</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/utsaw"/>
    <language>en</language>
    <item>
      <title>Enhance Your Search Capabilities with MongoDB Atlas: Advanced Querying Techniques</title>
      <dc:creator>Utsav Upadhyay</dc:creator>
      <pubDate>Sun, 02 Jul 2023 18:09:43 +0000</pubDate>
      <link>https://dev.to/utsaw/enhance-your-search-capabilities-with-mongodb-atlas-advanced-querying-techniques-il</link>
      <guid>https://dev.to/utsaw/enhance-your-search-capabilities-with-mongodb-atlas-advanced-querying-techniques-il</guid>
      <description>&lt;p&gt;Welcome back to the second part of our blog series on MongoDB Atlas Full-Text Search. In the first part, "&lt;a href="https://dev.to/utsaw/from-indexing-to-querying-how-mongodbs-full-text-search-stacks-up-against-elasticsearch-51mp"&gt;From Indexing to Querying: How MongoDB's Full-Text Search Stacks Up Against Elasticsearch&lt;/a&gt;," we explored the fundamentals of MongoDB's full-text search and compared it to Elasticsearch. If you haven't read it yet, we highly recommend starting there to get a comprehensive understanding of MongoDB's full-text search capabilities. In this blog post, we will dive deeper into MongoDB Atlas Full-Text Search and explore advanced querying techniques that will enable you to take full advantage of its powerful features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Compound Queries.
&lt;/h2&gt;

&lt;p&gt;Compound queries are very important and powerful when it comes to real-world use cases.&lt;br&gt;
A compound operator in MongoDB combines multiple operators to form a single query. Each part of the compound query is referred to as a clause, and each clause contains one or more sub-queries.&lt;/p&gt;

&lt;p&gt;A compound query has the following &lt;strong&gt;syntax&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  $search: {
    "index": &amp;lt;index name&amp;gt;, // optional, defaults to "default"
    "compound": {
      &amp;lt;must | mustNot | should | filter&amp;gt;: [ { &amp;lt;clauses&amp;gt; } ],
      "score": &amp;lt;options&amp;gt;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Each must, mustNot, should, and filter clause contains an array of subclauses. Use array syntax even if the array contains only one subclause.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We required the following terms to construct the query, which we also explained above - &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Document&lt;/strong&gt; for explaining all the queries -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "_id" : 1,
  "type" : "apple",
  "description" : "Apples come in several varieties, including Fuji, Granny Smith, and Honeycrisp.",
  "category" : "nonorganic",
  "in_stock" : false
},
{
  "_id" : 2,
  "type" : "banana",
  "description" : "Bananas are usually sold in bunches of five or six.",
  "category" : "nonorganic",
  "in_stock" : true
},
{
  "_id" : 3,
  "type" : "pear",
  "description" : "Bosc and Bartlett are the most common varieties of pears.",
  "category" : "organic",
  "in_stock" : true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt; - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;must&lt;/strong&gt;
Clauses that must match for a document to be included in the results. The returned score is the sum of the scores of all the subqueries in the clause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Maps to the AND boolean operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.col.aggregate([
  {
    $search: {
      "compound": {
        "must": [{
          "text": {
            "query": "varieties",
            "path": "description"
          }
        }]
      }
    }
  }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt; : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the above query we are searching for the term &lt;code&gt;Varieties&lt;/code&gt; in the field &lt;code&gt;description&lt;/code&gt; which is called &lt;code&gt;path&lt;/code&gt; in the query, and this query will return only those document which contains this - &lt;code&gt;Varieties&lt;/code&gt; term in the field - &lt;code&gt;description&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mustNot&lt;/strong&gt;
Clauses that must not match for a document to be included in the results. mustNot clauses don't contribute to a returned document's score.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Maps to the AND NOT boolean operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.col.aggregate([
  {
    $search: {
      "compound": {
        "mustNot": [{
          "text": {
            "query": "apples",
            "path": "description"
          }
        }]
      }
    }
  }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt; : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the above query we are searching for the data which do not contains apples in the field description, so this query will return only those documents which do not have apples in the field description.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;should&lt;/strong&gt;
Clauses that you prefer to match in documents that are included in the results. Documents that contain a match for a should clause have higher scores than documents that don't contain a should clause. The returned score is the sum of the scores of all the subqueries in the clause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use more than one should clause, you can use the minimumShouldMatch option to specify a minimum number of should clauses that must match to include a document in the results. If omitted, the minimumShouldMatch option defaults to 0.&lt;/p&gt;

&lt;p&gt;Maps to the OR boolean operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.col.aggregate([
  {
    $search: {
      "compound": {
        "Should": [{
          "text": {
            "query": "apples",
            "path": "description"
          }
        }]
      }
    }
  }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt; : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the above query we are searching for the data which contains apples in the field description, so this query will return those documents which have apples in the field description.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;for a better understanding of this Should operator which is the OR operator also, here is a second example -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.col.aggregate([
  {
    $search: {
      "compound": {
        "Should": [{
          "text": {
            "query": "apples",
            "path": "description"
          },
          "text": {
            "query": "Banana",
            "path": "description"
          }
        }],
          "minimumShouldMatch": 1
      }
    }
  }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt; : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the above query we are searching for the data which contains &lt;code&gt;apples&lt;/code&gt; OR &lt;code&gt;Banana&lt;/code&gt; in the field &lt;code&gt;description&lt;/code&gt;, so this &lt;code&gt;query&lt;/code&gt; will return those documents which have either apples or Banana in the field &lt;code&gt;description&lt;/code&gt;, also if you noticed we added &lt;code&gt;"minimumShouldMatch": 1&lt;/code&gt; in this query, &lt;code&gt;minimumShouldMatch&lt;/code&gt; means specify a minimum number of should clauses that must match to include a document in the results(the given term has to occur specific times whatever we pass as a parameter, &lt;code&gt;default&lt;/code&gt; it is 0)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;filter&lt;/strong&gt;
Clauses must all match for a document to be included in the results. filter clauses do not contribute to a returned document's score.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;in other words, it is a replacement of $in operator in full-text search.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;filter behaves the same as must, except that the filter clause is not considered in a returned document's score, and therefore does not affect the order of the returned documents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$search: {
  "compound": {
    "filter": [{
      "text": {
        "query": ["CLIENT", "PROFESSIONAL"],
        "path": "role"
      }
    }]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, as we understand all the important operators of full-text search, here a an example of a query which combines all these operators to get the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt; -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.col.aggregate([
  {
    $search: {
      "compound": {
        "must": [{
          "text": {
             "query": "varieties",
             "path": "description"
          }
        }], 
        "mustNot": [{
          "text": {
            "query": "apples",
            "path": "description"
          }
        }],
        "should": [
          {
            "text": {
              "query": "Fuji",
              "path": "description"
            }
          },
          {
            "text": {
              "query": "Golden Delicious",
              "path": "description"
            }
          }],
          "minimumShouldMatch": 2
        }
      }
    }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The following example uses a combination of &lt;code&gt;must&lt;/code&gt;, &lt;code&gt;mustNot&lt;/code&gt;, &lt;code&gt;Should&lt;/code&gt;clauses to construct a &lt;code&gt;query&lt;/code&gt;. The &lt;code&gt;must&lt;/code&gt;clause uses the text operator to &lt;code&gt;search&lt;/code&gt;for the term &lt;code&gt;varieties&lt;/code&gt;in the description field. For a document to match, it must fulfil the &lt;code&gt;must&lt;/code&gt;clause. The &lt;code&gt;mustNot&lt;/code&gt;clause performs a &lt;code&gt;search&lt;/code&gt;operation for the term &lt;code&gt;apples&lt;/code&gt;in the &lt;code&gt;description&lt;/code&gt;field. For a document to match, it must not fulfil the &lt;code&gt;mustNot&lt;/code&gt;clause. The &lt;code&gt;Should&lt;/code&gt; clause uses the text operator to &lt;code&gt;search&lt;/code&gt;for the term &lt;code&gt;Fuji&lt;/code&gt; or &lt;code&gt;Golden Delicious&lt;/code&gt; in the description field. For a document to match either of them at least 2 times i.e. &lt;code&gt;minimumShouldMatch&lt;/code&gt; we used, it will return any terms or both terms given if it occurs more than 1.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope you find this blog post informative and helpful as you dive deeper into MongoDB Atlas Full-Text Search. Happy querying!&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>database</category>
      <category>tutorial</category>
      <category>nosql</category>
    </item>
    <item>
      <title>From indexing to querying: How MongoDB's full-text search stacks up against ElasticSearch.</title>
      <dc:creator>Utsav Upadhyay</dc:creator>
      <pubDate>Sun, 09 Apr 2023 17:17:07 +0000</pubDate>
      <link>https://dev.to/utsaw/from-indexing-to-querying-how-mongodbs-full-text-search-stacks-up-against-elasticsearch-51mp</link>
      <guid>https://dev.to/utsaw/from-indexing-to-querying-how-mongodbs-full-text-search-stacks-up-against-elasticsearch-51mp</guid>
      <description>&lt;p&gt;&lt;a href="https://www.mongodb.com/docs/"&gt;MongoDB&lt;/a&gt; has been one of the most popular &lt;strong&gt;NoSQL databases&lt;/strong&gt; in recent years, and its popularity continues to grow among developers and technology communities.&lt;br&gt;
Some Major reasons for that is it's - &lt;strong&gt;Flexibility, Scalability, Performance, Cloud-Based, Integration and community&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But When it comes to &lt;strong&gt;Full-text search&lt;/strong&gt; there are very few options available and suitable, in which &lt;strong&gt;ElasticSearch&lt;/strong&gt; is the elephant amongst all, followed by &lt;strong&gt;Solr&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;So, What is &lt;strong&gt;Full text search&lt;/strong&gt; ?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Full-text search is a feature that allows you to use natural language queries to search through text data for specific words or phrases. It's commonly used in applications like search engines, e-commerce sites, and content management systems, where the ability to search through large amounts of text data quickly and accurately is critical.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;MongoDB developer has been continuously working over the past year to provide us this full text search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use MongoDB Atlas Full text search:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By Using MongoDB Atlas search we can easily search the terms into the specific fields of our database, also, we can use the  &lt;strong&gt;Operators to search words or Phrases, Operators like - AND, OR, NOT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For Using MongoDB Atlas Full text search, we need to take care some steps and rules/syntax.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a MongoDB Atlas Cluster:&lt;/strong&gt; If you haven't already, sign up for MongoDB Atlas and create a new cluster. Make sure to choose a cluster tier that supports Full-Text Search, such as M10 or above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Full-Text Search:&lt;/strong&gt; Once your cluster is configured, go to the Atlas UI's "Indexes" tab and click "Add Index." Select "Full-Text Search" as the index type and the fields to index. Then, to enable Full-Text Search for your cluster, click "Create Index. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7lkFsZID--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lzr44lw6iwqscj0pzyhs.png" alt="MongoDB Atlas full text search" width="800" height="277"&gt; &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure Search:&lt;/strong&gt; After you've enabled Full-Text Search, you can configure your search settings using the "Search Configuration" tab in the Atlas UI. Here, you need to configure the &lt;a href="https://www.mongodb.com/docs/manual/core/index-text/"&gt;index&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I would recommend &lt;strong&gt;Visual editor&lt;/strong&gt; for first time and it is easy to use.&lt;/li&gt;
&lt;li&gt;In the configure Search after selecting Visual editor we need to name our Index and select the Database and collection where we need to do Text Search.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.mongodb.com/docs/manual/core/index-text/"&gt;Index configuration&lt;/a&gt; and Field Mapping this is the most important step for our Full text search. In Index configuration we define &lt;strong&gt;Analyzers&lt;/strong&gt; and &lt;strong&gt;Fields/path&lt;/strong&gt; where we need to search, for example there is a field name products where you want to search product name. so, you will enter the field name in the &lt;strong&gt;Field Mappings&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;After making all these configuration you can click on save and it will start enabling all of your defined field and collection into full text search, this process will take a bit time and solely depend upon the size of the collection.&lt;/li&gt;
&lt;li&gt;Now you will see a dashboard like this where you can test your search but in a limited way example- by clicking on &lt;strong&gt;option query&lt;/strong&gt; you can search you single text or phrase in the interface.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TqfLCOI6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vv5alb1wjh74tdiv8cg0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TqfLCOI6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vv5alb1wjh74tdiv8cg0.png" alt="MongoDB Atlas search index" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;searching more than one or multiple words with Operators&lt;/strong&gt; like - AND, OR, NOT you need to write queries &lt;strong&gt;(see image for the reference)&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--68RIRlSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6l4s4gd8n8dc5vnbzty4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--68RIRlSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6l4s4gd8n8dc5vnbzty4.png" alt="MongoDB Atlas search" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now Let's comes to &lt;strong&gt;MongoDB Atlas Search Syntax and Basic Queries :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    db.collection.aggregate([
      {
        $search: {
          index: "your-index-name",
          "text": {
            "query": "your-word",
            "path": "field"
          }
        }
      } 
    ])  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation -&lt;/strong&gt; &lt;br&gt;
In the above query we are using aggregation as search is always works with aggregation, and by using. &lt;br&gt;
&lt;strong&gt;$search:&lt;/strong&gt; The $search stage performs a full-text search on the specified field or fields which must be covered by an Atlas Search index. defining Index is option, because if you not define index name it will always use the default one. but if you have multiple index then you need to defined. Also, best practice is to define index name.&lt;br&gt;
&lt;strong&gt;Query:&lt;/strong&gt; you will define the word which you are searching for. If you are searching for phrase then you need to change text: with phrase&lt;br&gt;
&lt;strong&gt;Path:&lt;/strong&gt; in the path we need to define the field where we are searching the word, We can define multiple paths in array forms too and it will only use those path which we defined at time of index making.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "_id" : 1,
  "type" : "apple",
  "description" : "Apples come in several varieties, including Fuji, Granny Smith, and Honeycrisp.",
  "category" : "nonorganic",
  "in_stock" : false
},
{
  "_id" : 2,
  "type" : "banana",
  "description" : "Bananas are usually sold in bunches of five or six.",
  "category" : "nonorganic",
  "in_stock" : true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the above data if we need to search a term like - Banana or Apple out of 2 documents above. we can easily search and return the document which contain this word.&lt;/p&gt;

&lt;p&gt;So suppose we need to &lt;strong&gt;Search&lt;/strong&gt; Bananas here and in the &lt;strong&gt;field&lt;/strong&gt; description and my index name is search-fruits - &lt;br&gt;
&lt;strong&gt;Query:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    db.collection.aggregate([
      {
        $search: {
          index: "search-fruits", //define your index name
          "text": {
            "query": "Bananas",
            "path": "description"
          }
        }
      } 
    ])  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this above query return 1 document out 2 because only 1 document contains Bananas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "_id" : 2,
  "type" : "banana",
  "description" : "Bananas are usually sold in bunches of five or six.",
  "category" : "nonorganic",
  "in_stock" : true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are &lt;strong&gt;more advance queries like&lt;/strong&gt; - compound search which use &lt;strong&gt;operators&lt;/strong&gt; like AND, OR, NOT (Should, Must, Mustnot) and features like - &lt;strong&gt;autocompletes, fuzzy searches&lt;/strong&gt; etc. We will cover these advance topics in next article very soon!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Few Points to consider before using MongoDB Atlas Full text search over ElasticSearch and Solr&lt;/strong&gt; - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Integrated within the database:&lt;/strong&gt; MongoDB Atlas Full-Text Search is integrated within the MongoDB database, whereas Elasticsearch and Solr are standalone search engines that must be integrated with a separate database. This integration can simplify the deployment and management process for users who already use MongoDB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native JSON support:&lt;/strong&gt; MongoDB stores data in a JSON-like format, and Atlas Full-Text Search leverages this format for indexing and searching. Elasticsearch and Solr also support JSON, but they use a different data structure and query syntax.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic indexing:&lt;/strong&gt; MongoDB Atlas Full-Text Search automatically indexes data as it's added to the database, making it easier for developers to implement search functionality without the need for a separate indexing process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale-out architecture:&lt;/strong&gt; MongoDB Atlas is designed to be scalable and can handle large amounts of data and concurrent users. It allows for the creation of replica sets and sharded clusters, making it easier to scale out search capacity as needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No need for dedicated search servers:&lt;/strong&gt; With MongoDB Atlas Full-Text Search, there is no need for a dedicated search server or infrastructure, unlike Elasticsearch or Solr. This can simplify the deployment and management process for users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; If you're already using MongoDB, using MongoDB Full-Text Search can be more cost-effective than using ElasticSearch, which requires additional infrastructure and management.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; In the end, the use of MongoDB Atlas Full-Text Search is entirely dependent on your specific use case. While it lacks the advanced features of Elasticsearch or Solr, it does provide a number of advantages such as ease of use, integration with the MongoDB ecosystem, and scalability. Finally, it is up to you to evaluate your specific needs and determine which full-text search engine will best meet them.&lt;/p&gt;

</description>
      <category>database</category>
      <category>mongodb</category>
      <category>elasticsearch</category>
      <category>search</category>
    </item>
    <item>
      <title>Streamlining Data Export to Excel: A comprehensive guide to using Python, Nodejs, PHP.</title>
      <dc:creator>Utsav Upadhyay</dc:creator>
      <pubDate>Wed, 11 Jan 2023 12:10:20 +0000</pubDate>
      <link>https://dev.to/utsaw/streamlining-data-export-to-excel-a-comprehensive-guide-to-using-python-nodejs-php-32co</link>
      <guid>https://dev.to/utsaw/streamlining-data-export-to-excel-a-comprehensive-guide-to-using-python-nodejs-php-32co</guid>
      <description>&lt;p&gt;Excel is a widely-used format for data analysis and reporting, and from our website or portal is most important feature nowadays, many libraries allow developers to export data in Excel format. There are several libraries and inbuilt features in programming languages which help us to export data in excel format, some languages and their libraries are listed below -&lt;/p&gt;

&lt;h2&gt;
  
  
  Python
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://xlsxwriter.readthedocs.io/"&gt;openpyxl&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://openpyxl.readthedocs.io/en/stable/#"&gt;xlsxwriter&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Nodejs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/exceljs/exceljs#readme"&gt;exceljs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/advisr-io/excel4node"&gt;excel4node&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  PHP
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://phpspreadsheet.readthedocs.io/en/latest/"&gt;PhpSpreadsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;(inbuilt .csv import method)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: I have only mentioned most used and versatile libraries which has all the features and fast in terms of speed with these features. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Although there are tonnes of libraries for excel but above library has the required features like - text hyperlink, combine columns/rows and text decorations and width controls etc, which is very hard to find in any other library.&lt;/p&gt;

&lt;h6&gt;
  
  
  Let's try how can we export data in excel using xlsxwriter in Python.
&lt;/h6&gt;

&lt;p&gt;Now before jump into creating an export to excel code, we need to learn some basics about excel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.xls:&lt;/strong&gt; The.xls file extension is used for Microsoft Excel 97-2003 workbooks. It supports Excel versions 97-2003 and has a maximum row and column count of 65,536. This extension, however, does not support certain Excel features such as macros, pivot tables, and data validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.xlsx:&lt;/strong&gt; Microsoft Excel 2007 and later versions use the.xlsx file extension. It can hold up to 1,048,576 rows and 16,384 columns. This file format also supports advanced Excel features like macros, pivot tables, and data validation.&lt;br&gt;
&lt;strong&gt;.xlsm:&lt;/strong&gt; Similar to.xlsx, the.xlsm file extension is used for workbooks that contain macros. It has the same row and column constraints as.xlsx.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.xlsb:&lt;/strong&gt; Also known as "Binary Excel," this file extension is faster and uses less memory than other Excel file formats. It is advised to use it with large datasets and complex calculations. It is, however, not human-readable and cannot be opened with a text editor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.csv:&lt;/strong&gt; This is a plain-text file format that can be opened by Excel, but it does not retain the original excel file's formatting and data types. It can only store data in tabular format and does not support formulas or styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.Odds:&lt;/strong&gt; This is an OpenDocument Spreadsheet file; it is an open spreadsheet standard that can be used by many spreadsheet programmes, including Apache OpenOffice Calc and LibreOffice Calc.&lt;br&gt;
It is not fully compatible with Excel, but it can open.ods files in Excel with some restrictions.&lt;/p&gt;

&lt;p&gt;Finally, the file extension you choose will be determined by the specific needs of your project and what you intend to do with the Excel file. . The most commonly used formats for compatibility and functionality are.xlsx and.xlsm, but.csv and .ods can be used for data exchange or open-source project compatibility. Because of their limitations,.xls and.xlsb are less commonly and less strongly recommended.&lt;/p&gt;

&lt;p&gt;Let's built a basic application with xlsxwriter.&lt;/p&gt;

&lt;p&gt;First we need to import xlsxwriter library with the help of PyPi&lt;br&gt;
&lt;code&gt;pip install XlsxWriter&lt;/code&gt;&lt;br&gt;
then we can import the library and write some basic export to excel application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import xlsxwriter

# Create a new workbook and add a worksheet
workbook = xlsxwriter.Workbook('example.xlsx')
worksheet = workbook.add_worksheet()

# Prepare data to be written to the worksheet
data = [['Name', 'Age', 'City'],
        ['John', 25, 'New York'],
        ['Mike', 32, 'Los Angeles'],
        ['Mary', 28, 'Chicago']]

# Write data to the worksheet
for row_num, row_data in enumerate(data):
    for col_num, cell_data in enumerate(row_data):
        worksheet.write(row_num, col_num, cell_data)

# Save the workbook
workbook.close()

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

&lt;/div&gt;



&lt;p&gt;Some feature about this library is it can also be accessible with Pandas too and we can use it with all the databases like -&lt;code&gt;SQL, MongoDB, Postgres etc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;xlsxwriter is a low-level library that provides a lot of flexibility and control over the Excel file format, which makes it useful for advanced Excel manipulation. However, it also makes the code slightly more complex when compared to other libraries such as pandas.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As you continue to explore the topic of data export to Excel using different libraries in programming languages, I invite you to reach out to me through comments, direct messaging here, or  on &lt;a href="https://twitter.com/utsav_hunt"&gt;Twitter&lt;/a&gt;. if you have any further questions or would like to request additional in-depth coverage of specific libraries in Node.js or PHP.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>tutorial</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
