Dragan Avramovic
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
Mapping Solr and ElasticSearch DQL paramethers === [toc] ## Basic Search Both Solr and Elasticsearch are powerful search engines, but they have some differences in their query languages. Let's compare some common search parameters in both systems: 1. **Basic Text Search:** - Solr: In Solr, you can use the `q` parameter to perform a basic text search. For example, `q=title:search`. - Elasticsearch: In Elasticsearch, the equivalent query can be constructed using the `match` query. For example, `{"match": {"title": "search"}}`. 2. **Filtering Results:** - Solr: Solr uses the `fq` parameter for filtering results. For example, `fq=category:electronics`. - Elasticsearch: In Elasticsearch, you can use the `filter` clause within a query. For example, `{"bool": {"filter": {"term": {"category": "electronics"}}}}`. 3. **Sorting:** - Solr: Solr uses the `sort` parameter to specify sorting criteria. For example, `sort=price asc`. - Elasticsearch: In Elasticsearch, sorting can be specified within the query using the `"sort"` field. For example, `{"sort": [{"price": "asc"}]}`. 4. **Faceted Search (Filtering by Categories):** - Solr: Solr supports faceted search through the `facet` and `facet.field` parameters. For example, `facet=true&facet.field=category`. - Elasticsearch: Elasticsearch provides aggregation for similar functionality. You can use an aggregation to achieve faceted search. For example, an aggregation for categories. 5. **Full-text Search:** - Solr: Solr provides powerful full-text search capabilities out of the box. - Elasticsearch: Elasticsearch also excels in full-text search and can be tuned for relevance scoring. 6. **Pagination:** - Solr: Solr uses the `start` and `rows` parameters for pagination. For example, `start=0&rows=10` retrieves the first 10 results. - Elasticsearch: Elasticsearch uses the `"from"` and `"size"` parameters for pagination. For example, `{"from": 0, "size": 10}` retrieves the first 10 results. 7. **Fuzzy Search:** - Both Solr and Elasticsearch support fuzzy search. In Solr, you can use the `~` operator (e.g., `term~`) and in Elasticsearch, you can use the `"fuzziness"` parameter. 8. **Boosting:** - Both Solr and Elasticsearch allow you to boost the relevance of specific fields or terms in your queries. These are just some common search parameters, and both Solr and Elasticsearch offer a wide range of advanced features for complex search requirements. When transitioning from Solr to Elasticsearch, you may need to adapt your queries and indexing strategies to match Elasticsearch's data model and query capabilities. ## Advanced Search Let's dive into Solr's "fl" (Field List) and "fq_list" (Filter Query List) parameters, which are specific to Solr and are not directly equivalent in Elasticsearch's DQL. These parameters are often used to control the fields to return in the search results and to apply multiple filter queries simultaneously. 1. **"fl" (Field List) Parameter:** - `fl` is used to specify which fields from the documents should be returned in the search results. You can use it to control the fields that you want to retrieve to reduce the size of the response and improve query performance. - For example, if you only want to retrieve the "title" and "price" fields, you can use `fl=title,price`. - In Elasticsearch, you can achieve a similar result by using the "_source" field filtering. When indexing documents in Elasticsearch, you can specify which fields should be stored in the "_source" field. When querying, you can use "_source" filtering to retrieve specific fields. ```json { "_source": ["title", "price"], "query": { "match": { "title": "search" } } } ``` This will only return the "title" and "price" fields in the Elasticsearch search results. 2. **"fq_list" (Filter Query List) Parameter:** - `fq_list` is not a standard Solr parameter, but it's often used to pass a list of filter queries as a single parameter. This can be useful when you want to apply multiple filter queries to narrow down your search results. - For example, if you want to filter by both "category:electronics" and "price:[100 TO 500]", you can use `fq_list=category:electronics,price:[100 TO 500]`. - In Elasticsearch, you typically construct a JSON query that includes multiple filter clauses using a "bool" query with "must" or "filter" clauses to achieve similar filter combinations. Here's an example: ```json { "query": { "bool": { "filter": [ { "term": { "category": "electronics" } }, { "range": { "price": { "gte": 100, "lte": 500 } } } ] } } } ``` This Elasticsearch query filters documents where the "category" is "electronics" and the "price" falls between 100 and 500. So, while there isn't a direct "fq_list" equivalent in Elasticsearch, we can achieve similar functionality by constructing Elasticsearch queries with multiple filter clauses. Additionally, "_source" filtering can be used to control which fields are returned in the results, similar to Solr's "fl" parameter. ## ``qf``, ``wt``, ``bf``, ``boost``, ``tie``, ``defType``, ``mm`` paramethers 1. **"qf" (Query Fields):** - In Solr, "qf" is used to specify the fields that should be considered when parsing and executing the main query. It allows you to define a weighted list of fields for a query. - In Elasticsearch, you can achieve a similar effect by specifying the "fields" parameter within the "multi_match" query, where you can list multiple fields and control their weights. - Example in Solr: `qf=title^2.0 content^1.0`. - Equivalent in Elasticsearch: ```json { "query": { "multi_match": { "query": "search", "fields": ["title^2.0", "content^1.0"] } } } ``` 2. **"wt" (Response Writer):** - "wt" specifies the response format in Solr (e.g., JSON, XML, etc.). - In Elasticsearch, the response format is typically JSON by default, so you don't need a separate parameter to specify it. 3. **"bf" (Boost Functions):** - "bf" is used in Solr to specify functions that are used to boost document scores. These functions can be used to influence the relevance score of search results. - In Elasticsearch, you can achieve similar boosting using various query parameters like "boost" or by incorporating function score queries. 4. **"boost" Parameter:** - In Solr, "boost" is used to apply a boost factor to a specific query or filter. It allows you to boost the importance of certain queries. - In Elasticsearch, you can use the "boost" parameter within query clauses to achieve the same effect. - Example in Solr: `q=search&boost=category:electronics^2.0`. - Equivalent in Elasticsearch: ```json { "query": { "bool": { "should": [ { "match": { "title": "search" } } ], "filter": { "term": { "category": "electronics" } }, "boost": 2.0 } } } ``` 5. **"tie" Parameter:** - "tie" in Solr specifies the tiebreaker in case of a multi-field search query. It affects the relevance score. - In Elasticsearch, you can control the tiebreaker through the "dis_max" or "bool" query's "tie_breaker" parameter. 6. **"defType" (Default Query Parser Type):** - "defType" specifies the default query parser type to use in Solr (e.g., "dismax" or "edismax"). - In Elasticsearch, the default query parser type is typically specified in the query itself (e.g., "match" query or "multi_match" query). 7. **"mm" (Minimum Should Match):** - "mm" parameter in Solr specifies how many "should" clauses must match in a boolean query. - In Elasticsearch, you can control the minimum should match behavior within the "bool" query using the "minimum_should_match" parameter. It's important to note that while there are some similarities between Solr and Elasticsearch query parameters, they have their own query DSL and specific ways of achieving similar functionality. The exact translation may require adapting our queries to the Elasticsearch DSL based on your specific use case and query requirements. ### Elasticsearch DSL (Domain-Specific Language) Elasticsearch DSL (Domain-Specific Language) is a powerful and flexible query language used to interact with Elasticsearch, a distributed search and analytics engine. Elasticsearch DSL allows you to construct and execute a wide range of queries and aggregations to retrieve, filter, and analyze data stored in Elasticsearch. Here are some key features and components of Elasticsearch DSL: 1. **Query Types:** Elasticsearch DSL provides various query types to match and retrieve documents based on different criteria. Some common query types include: - **Match Query:** Matches a specific field with a given value. - **Term Query:** Matches documents that contain an exact term in a specified field. - **Bool Query:** Combines multiple queries using boolean operators (AND, OR, NOT). - **Range Query:** Matches documents with field values within a specified range. - **Wildcard Query:** Allows wildcard pattern matching. - **Fuzzy Query:** Matches documents with similar terms using fuzzy matching. - **Prefix Query:** Matches documents with a field containing a specific prefix. - **Nested Query:** Performs queries within nested documents. 2. **Aggregations:** Elasticsearch DSL supports aggregations, which allow you to perform analytics on your data. You can calculate statistics, create histograms, date histograms, and more. 3. **Filters:** Filters are used to narrow down the result set by applying conditions to the documents. Filters are often used for performance optimization. 4. **Sorting:** We can specify sorting criteria to order the search results. 5. **Highlighting:** Elasticsearch DSL supports highlighting, which allows you to highlight matching terms in the search results. 6. **Scripting:** We can use scripts in Elasticsearch DSL to perform custom calculations or transformations on the data during query execution. 7. **Boosting:** We can assign different levels of importance or relevance to specific queries or parts of a query. 8. **Geospatial Queries:** Elasticsearch DSL provides geospatial queries to work with location data, such as finding documents within a certain distance of a specified point. Here's an example of a simple Elasticsearch DSL query in JSON format: ```json { "query": { "bool": { "must": [ { "match": { "title": "search" } } ], "filter": [ { "term": { "category": "electronics" } } ] } }, "sort": [ { "price": "asc" } ], "size": 10 } ``` In this example, the query is a boolean query with a "must" clause for matching the "title" field with "search" and a "filter" clause for filtering documents with the "category" field set to "electronics." The results are sorted by the "price" field in ascending order, and only the top 10 results are returned. Elasticsearch DSL offers a rich set of features and is highly extensible, making it suitable for various use cases, including full-text search, log analysis, and data exploration. It's essential to understand the DSL's capabilities to effectively query and analyze data in Elasticsearch.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully