CINXE.COM
Search Tips - Sunnah.com - Sayings and Teachings of Prophet Muhammad (صلى الله عليه و سلم)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" translate="no"> <head> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-PD11DFYVJC"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-PD11DFYVJC'); </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="EN"/> <meta name="description" content="Hadith of the Prophet Muhammad (saws) in English and Arabic"/> <meta name="keywords" content="hadith, hadeeth, sunnah, bukhari, muslim, sahih, sunan, tirmidhi, nawawi, holy, arabic, iman, islam, Allah, book, english"/> <meta name="Charset" content="UTF-8"/> <meta name="Distribution" content="Global"/> <meta name="Rating" content="General"/> <meta property="og:image" content="https://sunnah.com/images/hadith_icon2_huge.png" /> <meta name="csrf-param" content="_csrf_frontend"> <meta name="csrf-token" content="jt5vZLL0NyORjI2jc56X7FODNRCWcp8cezsdNF8L9CTotxZQ5cxYd_q61e1H2tybIsRTSuIjrU4-XClOL3rZSQ=="> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/css/all.css?ver=1743444314" media="screen" rel="stylesheet" type="text/css" /> <link href="/css/donate.css?ver=1741473009" media="screen" rel="stylesheet" type="text/css" /> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="128x128" href="/favicon-128x128.png"> <link rel="image_src" href="/images/hadith_icon2.png" /> <link rel="apple-touch-icon" href="/images/apple-touch-icon.png" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="/js/jquery.cookie.js"></script> <!--<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js" async></script>--> <script> </script> <script src="/js/sunnah.js?ver=1728262226"></script> <!--<script src="https://apis.google.com/js/platform.js" async defer></script>--> <title> Search Tips - Sunnah.com - Sayings and Teachings of Prophet Muhammad (صلى الله عليه و سلم) </title> </head> <body> <div id="fb-root"></div> <div id="site"> <div id="header"> <!-- Donation Header --> <div id="donation-header"> <div class="donation-header-content"> <span>Contribute to our mission</span> <a href="/donate" class="donate-now-btn">Donate Now</a> </div> </div> <div id="toolbar"> <div id="toolbarRight"> <a href="https://quran.com">Qur'an</a> | <a href="https://sunnah.com"><b>Sunnah</b></a> | <a href="https://salah.com">Prayer Times</a> | <a href="https://quranicaudio.com">Audio</a> <div id="toggle-theme-btn"> <img id="sun_theme_toogle_btn" src="/images/sun_icon.svg" alt="toggle Light Thme" /> <img id="moon_theme_toggle_btn" src="/images/moon_icon.svg" alt="toggle Dark Thme" /> </div> <script> const sun = document.getElementById("sun_theme_toogle_btn"); const moon = document.getElementById("moon_theme_toggle_btn"); const toggleThemeButtons = (theme) => { if (theme == 'light') { sun.style.display = "none"; moon.style.display = "block"; } else if (theme == 'dark'){ sun.style.display = "block"; moon.style.display = "none"; } }; const updateTheme = (theme) => { toggleThemeButtons(theme); document.body.setAttribute('data-theme', theme); localStorage.setItem('theme', theme); }; const initializeTheme = () => { const savedTheme = localStorage.getItem("theme"); const preferredColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; if(savedTheme) updateTheme(savedTheme); else if(preferredColorScheme) updateTheme(preferredColorScheme); else updateTheme('light'); }; sun.addEventListener("click", () => updateTheme("light")); moon.addEventListener("click", () => updateTheme("dark")); initializeTheme(); </script> </div> </div> <a href="https://sunnah.com"><div id="banner" class=bannerTop></div></a> <!-- <a href="#"><div id=back-to-top></div></a> --> <div id="search"> <div class="search-container"> <div id="searchbar"> <form name="searchform" action="/search/" method="get" id="searchform"> <input type="text" class="searchquery" name="q" placeholder="Search …" /> <input type="submit" class="searchsubmit search-btn" value="l" /> </form> </div> <button type="button" id="filterBtn" class="custom-btn"> <span class="custom-btn-content filter-icn"> <i class="fa-solid fa-sliders"></i> </span> </button> <button type="button" id="tipsBtn" class="custom-btn searchtipslink"> <span class="custom-btn-content tips-icn"> <i class="fa-solid fa-lightbulb"></i> </span> </button> </div> <!-- Modal for selecting collections --> <div id="filterModal" class="modal"> <div class="modal-content"> <span class="close">×</span> <h2 class="header">Select Collections</h2> <div id="collectionChips"> <div class="chip " data-value="bukhari">Sahih al-Bukhari</div><div class="chip " data-value="muslim">Sahih Muslim</div><div class="chip " data-value="nasai">Sunan an-Nasa'i</div><div class="chip " data-value="abudawud">Sunan Abi Dawud</div><div class="chip " data-value="tirmidhi">Jami` at-Tirmidhi</div><div class="chip " data-value="ibnmajah">Sunan Ibn Majah</div><div class="chip toggleable-chip hidden" data-value="malik">Muwatta Malik</div><div class="chip toggleable-chip hidden" data-value="ahmad">Musnad Ahmad</div><div class="chip toggleable-chip hidden" data-value="darimi">Sunan ad-Darimi</div><div class="chip toggleable-chip hidden" data-value="nawawi40">An-Nawawi's 40 Hadith</div><div class="chip toggleable-chip hidden" data-value="riyadussalihin">Riyad as-Salihin</div><div class="chip toggleable-chip hidden" data-value="adab">Al-Adab Al-Mufrad</div><div class="chip toggleable-chip hidden" data-value="shamail">Ash-Shama'il Al-Muhammadiyah</div><div class="chip toggleable-chip hidden" data-value="mishkat">Mishkat al-Masabih</div><div class="chip toggleable-chip hidden" data-value="bulugh">Bulugh al-Maram</div><div class="chip toggleable-chip hidden" data-value="forty">Collections of Forty</div><div class="chip toggleable-chip hidden" data-value="hisn">Hisn al-Muslim</div><div id="showMoreLessBtn" class="show-more-btn">Show More Collections</div> </div> <button id="applyFilterBtn" class="apply-btn">Apply</button> </div> </div> <div id="searchtips"> <div class="clear"></div> <b>Quotes</b> e.g. "pledge allegiance"<br> Searches for the whole phrase instead of individual words <p> <b>Wildcards</b> e.g. test*<br> Matches any set of one or more characters. For example test* would result in test, tester, testers, etc. <p> <b>Fuzzy Search</b> e.g. swore~<br> Finds terms that are similar in spelling. For example swore~ would result in swore, snore, score, etc. <p> <b>Term Boosting</b> e.g. pledge^4 hijrah<br> Boosts words with higher relevance. Here, the word <i>pledge</i> will have higher weight than <i>hijrah</i> <p> <b>Boolean Operators</b> e.g. ("pledge allegiance" OR "shelter) AND prayer<br> Create complex phrase and word queries by using Boolean logic. <p> <a href="/searchtips">More ...</a> <div class="clear"></div> </div> </div> <script> document.addEventListener("DOMContentLoaded", function () { const filterBtn = document.getElementById("filterBtn"); const filterModal = document.getElementById("filterModal"); const closeModal = document.querySelector("#filterModal .close"); const applyFilterBtn = document.getElementById("applyFilterBtn"); const chipElements = document.querySelectorAll("#collectionChips .chip"); const searchForm = document.getElementById("searchform"); const filterIcon = document.getElementById("filterIcon"); // Parse URL parameters for collections (PHP style array params) const urlParams = new URLSearchParams(window.location.search); let selectedCollections = []; let index = 0; while (urlParams.has(`collection[${index}]`)) { selectedCollections.push(urlParams.get(`collection[${index}]`)); index++; } // Initialize chip selection based on URL parameters chipElements.forEach(chip => { if (selectedCollections.includes(chip.dataset.value)) { chip.classList.add("selected"); } }); // Open modal filterBtn.addEventListener("click", function () { filterModal.style.display = "block"; }); // Close modal (x) closeModal.addEventListener("click", function () { filterModal.style.display = "none"; }); // Close modal if clicking outside window.addEventListener("click", function (event) { if (event.target === filterModal) { filterModal.style.display = "none"; } }); // Toggle chip selection chipElements.forEach(chip => { chip.addEventListener("click", function () { const value = chip.dataset.value; chip.classList.toggle("selected"); if (chip.classList.contains("selected")) { selectedCollections.push(value); } else { selectedCollections = selectedCollections.filter(col => col !== value); } }); }); function submit() { const queryInput = document.querySelector(".searchquery").value; let actionUrl = "/search/?q=" + encodeURIComponent(queryInput); selectedCollections.forEach((col, index) => { actionUrl += `&collection[${index}]=${encodeURIComponent(col)}`; }); window.location.href = actionUrl; } // "Apply" button applyFilterBtn.addEventListener("click", function (event) { filterModal.style.display = "none"; submit() event.preventDefault() }); // Intercept search form to include selected collections searchForm.addEventListener("submit", function (event) { submit() event.preventDefault(); }); const showMoreLessBtn = document.getElementById("showMoreLessBtn"); let isHidden = true; if (showMoreLessBtn) { showMoreLessBtn.addEventListener("click", function () { $(".toggleable-chip").toggleClass("hidden"); isHidden = !isHidden this.textContent = isHidden ? "Show More Collections" : "Show Less" ; }); } }); </script> <style> [data-theme="light"] { --secondary-block-bg: #ebebeb; --chip-bg: rgba(0, 0, 0, 0.075); --chip-hover-bg: #dedede; --chip-selected-bg: #3ba08f; --border-color: rgba(0, 0, 0, 0.2); --button-highlight-color: rgba(251, 250, 248, 0.2); --search-icon-color: var(--chip-selected-bg); } [data-theme="dark"] { --secondary-block-bg: #343A40; --chip-bg: rgba(44, 48, 52, .7); --chip-hover-bg: #3d4648; --chip-selected-bg: #3ba08f; --border-color: rgba(255, 255, 255, 0.2); --button-highlight-color: #1c625d; --search-icon-color: #ffffff; } [data-theme="light"] .header { color: #3d9393; } .clear { clear: both; } /* Search Container Layout */ .search-container { display: flex; gap: 10px; align-items: stretch; } /* Left Column Layout */ .left-column { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; } /* Searchbar Layout */ #searchbar { flex: 1; display: flex; align-items: center; } #searchform { display: flex; gap: 10px; width: 100%; } .searchquery { flex: 1; height: 32px; } .searchsubmit { width: 40px; flex-shrink: 0; } .filter-icn::after { content: "Filter"; padding-left: 5px; } .tips-icn::after { content: "Tips"; padding-left: 5px; } .search-btn { background-color: var(--highlight-color); color: var(--search-icon-color); border-top-right-radius: 5px; border-bottom-right-radius: 5px; } .custom-btn { padding: 6px 12px; cursor: pointer; background-color: rgba(0, 0, 0, 0); color: white; border: none; border-radius: 10px; font-family: "Akzidenz Roman", Arial, sans-serif; white-space: nowrap; flex-shrink: 0; } .custom-btn:hover { background-color: var(--button-highlight-color); ; } .custom-btn-content { display: flex; align-items: center; justify-content: center; } .apply-btn { padding: 1rem 2rem; cursor: pointer; background-color: var(--chip-selected-bg); color: white; border: none; border-radius: 10px; font-family: "Akzidenz Roman", Arial, sans-serif; white-space: nowrap; flex-shrink: 0; align-self: flex-end; } .apply-btn:hover { background-color: #1c625d; } /* Modal */ .modal { display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4); } .modal-content { display: flex; flex-direction: column; background-color: var(--secondary-block-bg); color: var(--primary-text-color); margin: 100px auto; padding: 20px; border: 1px solid var(--border-color); width: 400px; position: relative; border-radius: 8px; } .modal-content .header { padding: 0; margin: 0; } .modal-content .close { position: absolute; top: 10px; right: 10px; color: var(--secondary-text-color); font-size: 24px; font-weight: bold; cursor: pointer; } .modal-content .close:hover { color: var(--primary-text-color); } #collectionChips { margin: 20px 0; flex: 1; } .chip { display: inline-block; padding: 8px 12px; margin: 4px; background-color: var(--chip-bg); color: var(--primary-text-color); border-radius: 16px; cursor: pointer; user-select: none; font-size: 13px; transition: background-color 0.2s ease; } .chip:hover { background-color: var(--chip-hover-bg); color: var(--primary-text-color); } .chip.selected { background-color: var(--chip-selected-bg); color: #fff; display: inline-block !important; } /* Show More/Less Button */ .show-more-btn { display: block; padding: 4px 12px; margin: 10px auto; background-color: transparent; color: var(--chip-selected-bg); border: 1px solid var(--chip-selected-bg); border-radius: 10px; cursor: pointer; user-select: none; font-size: 13px; transition: all 0.2s ease; text-align: center; width: fit-content; } .show-more-btn:hover { background-color: rgba(59, 160, 143, 0.1); } .toggleable-chip { display: inline-block; } .hidden { display: none } /* Responsive Design */ @media screen and (max-width: 760px) { .modal-content { box-sizing: border-box; width: 90vw; margin: 80px auto; } .custom-btn { padding: 6px 8px; } .filter-icn::after { content: ""; } .tips-icn::after { content: ""; } } </style> <div class=clear></div> <div class=crumbs><a href="/">Home</a> » Search Tips</div><div class=clear></div> </div> <div class=clear></div> <div id="topspace"></div> <div id="nonheader"> <div class="sidePanelContainer"> <div style="height: 1px;"></div> <div id="sidePanel"> </div> </div><!-- sidePanelContainer close --> <div class="mainContainer"><div id="main"> <div class=clear></div> <div class="about"> <a name="SearchTips"><div class=section>Search tips and tricks</div></a> <div class=content> <p>In order to unleash the true power of our search engine, we've provided you the following tips and tricks to help you narrow down exactly what you are looking for.</p> <p>This list has been compiled from the official <a href="http://lucene.apache.org/core/old_versioned_docs/versions/2_9_1/queryparsersyntax.html" target="_blank">Lucene query parser syntax</a> page. <p><strong>1. Terms</strong></p> <p>A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases. A Single Term is a single word such as "pledge" or "allegiance". A Phrase is a group of words surrounded by double quotes such as "pledge allegiance". Multiple terms can be combined together with Boolean operators to form a more complex query (see below). <p><strong>2. Wildcard searches</strong></p> Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries).To perform a single character wildcard search use the "?" symbol. To perform a multiple character wildcard search use the "*" symbol. <br> The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "near" or "neat" you can use the search "nea?" (without quotes). <br> Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or testers, you can use the search "test*" (without quotes) You can also use the wildcard searches in the middle of a term, such as in "te*t". <br> Note: You cannot use a * or ? symbol as the first character of a search. <p><strong>3. Fuzzy searching</strong></p> Lucene supports fuzzy searches based on the Levenshtein Distance, or Edit Distance algorithm. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "swore" use the fuzzy search: "swore~". This search will find terms like swore, snore, score, etc. <br> Furthermore, an optional parameter can specify the required similarity. The value is between 0 and 1, with a value closer to 1 only terms with a higher similarity will be matched. For example:"swore~0.7" will yield only results that are close to the original query, such as swore, score, etc. <br> A search query "swore~0.3" will yield results that are slightly similar to the original query, such as swore, stone, swords, etc. <br> The default that is used if the parameter is not given is 0.5. <br> <p><strong>4. Proximity Searches</strong></p> Lucene supports finding words are a within a specific distance away. To do a proximity search use the tilde, "~", symbol at the end of a Phrase. For example to search for a "pledge" and "migration" within 10 words of each other in a document use the search: "pledge migration"~10. This will yield results in which the words pledge and migration are separated by no more then 10 words. Very helpful if you only know the context of what you are searching for. <br> <p><strong>5. Boosting a term</strong></p> <p>Lucene provides the relevance level of matching documents based on the terms found. To boost a term use the caret ("^") symbol with a boost factor (a number) at the end of the term you are searching. The higher the boost factor, the more relevant the term will be. Boosting allows you to control the relevance of a document by boosting its term. For example, if you are searching for <br><pre> pledge hijrah</pre> and you want the term "pledge" to be more relevant, boost it using the ^ symbol along with the boost factor next to the term. You would type: <br> <pre> pledge^4 hijrah</pre> This will make results with the term pledge appear more relevant. You can also boost Phrase Terms as in the example: <br> <pre> "pledge of allegiance"^5 requested</pre> By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2) <br> <p><strong>6. Boolean operators </strong></p> <p>Boolean operators allow terms to be combined through logic operators. Lucene supports AND, "+", OR, NOT and "-" as Boolean operators (Note: Boolean operators must be ALL CAPS).</p> <br> <strong>The "OR" Operator</strong> <p>The OR operator is the default conjunction operator. This means that if there is no Boolean operator between two terms, the OR operator is used. The OR operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets. The symbol || can be used in place of the word OR. <p>To search for documents that contain either "pledge allegiance" or just "pledge" use the query: <pre> "pledge allegiance" pledge</pre> or <pre> "pledge allegiance" OR pledge</pre> <br> <p><strong>The "AND" Operator</strong></p> <p>The AND operator matches documents where both terms exist anywhere in the text of a single document. This is equivalent to an intersection using sets. The symbol && can be used in place of the word AND. <p>To search for documents that contain "pledge of Allegiance" and "second time" use the query: <pre> "pledge of Allegiance" AND "second time"</pre> <br> <p><strong>The "+" Operator</strong></p> <p>The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document. <p>To search for documents that must contain "pledge" and may contain "allegiance" use the query: <pre> +pledge allegiance</pre> <br> <p><strong>The "NOT" Operator</strong></p> <p>The NOT operator excludes documents that contain the term after NOT. This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT. <p>To search for documents that contain "pledge allegiance" but not "second time" use the query: <pre> "pledge of Allegiance" NOT "second time"</pre> <p>Note: The NOT operator cannot be used with just one term. For example, the following search will return no results: <pre> NOT "pledge allegiance"</pre> <br> <p><strong>The "-" Operator</strong></p> <p>The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.</p> <br> <p>To search for documents that contain "pledge allegiance" but not "allegiance to the Messenger" use the query: <pre> "pledge allegiance"-"allegiance to the Messenger"</pre> <p><strong>7. Grouping</strong></p> <p>Lucene supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query. <p>To search for either "pledge" or "allegiance" and "prayer" use the query: <pre> (pledge OR allegiance) AND prayer</pre> This eliminates any confusion and makes sure you that prayer must exist and either term pledge or allegiance may exist. <br> </div> <br> </div> <div class="clear"></div> </div><!-- main close --> </div> <!-- mainContainer close --> <a href="#"><div id=back-to-top></div></a> <div class="clear"></div> </div> <!-- nonheader close --> <div class=footer> <a href="/about">About</a> | <a href="/news">News</a> | <a href="/support">Support</a> | <a href="/developers">Developers</a> | <a href="/contact">Contact</a> | <a href="/donate">Donate</a> <div class="sm_links"> <a href="https://www.facebook.com/Sunnahcom-104172848076350" target="_blank"><i class="icn-fb"></i></a> <a href="https://www.instagram.com/_sunnahcom/" target="_blank"><i class="icn-ig"></i></a> <a href="https://twitter.com/SunnahCom" target="_blank"><i class="icn-twitter"></i></a> </div> <div class=clear></div> </div> <script type="text/javascript"> var sc_project=7148282; var sc_invisible=1; var sc_security="63a57073"; </script> <link href="/css/fonts/fontello/css/icn-font.css?ver=1740090702" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script> <noscript> <div class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"> <img class="statcounter" src="https://c.statcounter.com/7148282/0/63a57073/1/" alt="Web Analytics"></a> </div> </noscript> <div class="clear"></div> </div><!-- site div close --> </body> </html>