ਸਮੱਗਰੀ 'ਤੇ ਜਾਓ

ਫਰਮਾ:Search link/doc

ਵਿਕੀਪੀਡੀਆ, ਇੱਕ ਆਜ਼ਾਦ ਵਿਸ਼ਵਕੋਸ਼ ਤੋਂ

This template creates a link that can be used to store a Wikipedia search box query. A search link is useful for collaborative search on Talk pages and most other pages, but it is not to be used in articles. If used in articles, it outputs the above warning.

Basics

[ਸੋਧੋ]

{{Search link|first|second|third}}

  • The first parameter is for the search, or query.
  • The second parameter is a label for the link.
  • The third parameter is the search domain.

The name of the template is Search link, or sl for short.
The second and third parameters are optional and have defaults, so the short form is {{sl|query}}.

Both a search link and a search box go to the same search engine. The same query produces the same result.

The basic search covers articles. It finds words and phrases composed of letters and numbers very quickly, but a basic search can also query for all articles that contain a string that includes punctuation, math, and other symbols as seen in the page content or as seen in the page wikitext.

Basic search principles when using a search link
1 {{Search link
|"search engine query"}}

"search engine query"

There is one search term, a phrase that produces 18 results, including a redirect. For one term, the page ranking rule is simple: title matches, on top. Two pages hit on "Search Engine Query" and one on "[[Search engine (computing)|search engine]] query".
2 {{Search link
|"search engine query"
insource:/"search engine query"/}}

"search engine query" insource:/"search engine query"/

Added a term: insource:/"slash delimited regex"/. Now there are 15. Three were filtered out because regex match only exact strings. All other searches always ignore capitalization, punctuation, math, and other symbols, like the ]] above. Proves a basic difference with search 1: only insource: searches wikitext. All other terms search what is rendered.
3 {{Search link
|search engine query}}

search engine query

There are three search terms. They produce 1169 results. Many page ranking rules apply to make the top most likely and the bottom least likely, probably.
4 {{Search link
|search engine query
insource:/"search engine query"/}}

search engine query insource:/"search engine query"/

Similar to search 3, the regex crawled character-by-character through the same 1169-page filter to produce its same 15 results. As much as that seems, 1169 is nothing compared to running an unfiltered (unaccompanied) regex exposed to the 1,80,482 pages on the wiki to produce some 15 results.[1]
5 {{Search link
|insource:/"2 + 2"/
prefix:Arithmetic
|"Arithmetic" titles & "2 + 2"}}

"Arithmetic" titles & "2 + 2"
The regexp is the first term, but the prefix: term first filters out all but a few titles that start with the characters A-r-i-t-h-m-e-t-i-c, then the regexp crawls character-wise. Perhaps such a label conveys this to your team.

This template differs from the search box superficially when searching for an equals sign. In the search box you just say =, but here you must use the five-letter string {{=}}.[2]

In search 5 notice the need for the double quotes around the search pattern: insource:/"slash delimited regexp"/. These protect any characters from being interpreted as regex metacharacters, and insures they are interpreted literally. In basic searches quotes are always used, to enable exact-string searches in the wikitext. In advanced searches the double quotes are not used, so that the metacharacters can act as conditional and branching operators to create generalized patterns.

Search 2 exemplifies the easiest filter to apply to accompany any regexp search. It just takes the same phrase and make it a separate term. Given any regexp insource/"exact string search"/, just accompany it by an insource:"exact string search". The later term will always act like a perfect filter, matching every alphanumeric, and ignoring every non-alphanumeric, speeding through an indexed search to filter out pages the regexp couldn't possibly match. As for other filters, a namespace is weak, but every additional term increases regex power.

The next section covers Search link arguments more in depth.

Advanced

[ਸੋਧੋ]

Here are the template parameters for Search link.

1 or |query= The search query. It becomes the text of the search link (how the link will look) so it accepts |text=.
2 or |label= A label to replace the default text. A new look to the link, so it also accepts |link=. Defaults to show the search query.
3

20

|3|4|5||20
or |ns=

The search domain: one or more namespaces abbreviated "nsx", where x is any namespace number.
|nsx|nsx|nsx|…|nsx, or ns=nsx&nsx&nsx…&nsx, or ns=all. Defaults to ns0.

|limit= Number of search results on the first page. Named parameter only, not positional.
Wikipedia data structure
ਨੇਮਸਪੇਸਾਂ
ਨੇਮਸਪੇਸ ਵਿਸ਼ਾ ਨੇਮਸਪੇਸ ਗੱਲਬਾਤ
0 (ਮੁੱਖ/ਲੇਖ) ਗੱਲ-ਬਾਤ 1
2 ਵਰਤੋਂਕਾਰ ਵਰਤੋਂਕਾਰ ਗੱਲ-ਬਾਤ 3
4 ਵਿਕੀਪੀਡੀਆ ਵਿਕੀਪੀਡੀਆ ਗੱਲ-ਬਾਤ 5
6 ਤਸਵੀਰ ਤਸਵੀਰ ਗੱਲ-ਬਾਤ 7
8 ਮੀਡੀਆਵਿਕੀ ਮੀਡੀਆਵਿਕੀ ਗੱਲ-ਬਾਤ 9
10 ਫਰਮਾ ਫਰਮਾ ਗੱਲ-ਬਾਤ 11
12 ਮਦਦ ਮਦਦ ਗੱਲ-ਬਾਤ 13
14 ਸ਼੍ਰੇਣੀ ਸ਼੍ਰੇਣੀ ਗੱਲ-ਬਾਤ 15
100 ਫਾਟਕ ਫਾਟਕ ਗੱਲ-ਬਾਤ 101
118 [[ਵਿਕੀਪੀਡੀਆ:ਡਰਾਫਟ|]] 119
710 TimedText TimedText talk 711
828 ਮੌਡਿਊਲ ਮੌਡਿਊਲ ਗੱਲ-ਬਾਤ 829
Deprecated
2300 [[ਵਿਕੀਪੀਡੀਆ:ਗੈਜੇਟ|]] 2301
2302 [[ਵਿਕੀਪੀਡੀਆ:ਗੈਜੇਟ|]] 2303
ਇੰਸਟਾਲ ਨਹੀਂ ਕੀਤਾ
90 ਥਰਿੱਡ ਥਰਿੱਡ ਗੱਲਬਾਤ 91
92 ਸੰਖੇਪ ਸੰਖੇਪ ਗੱਲਬਾਤ 93
108 ਪੁਸਤਕਾਂ Book ਗੱਲਬਾਤ 109
442 ਕੋਰਸ Course ਗੱਲਬਾਤ 443
444 ਇੰਸਟੀਟਿਊਸ਼ਨ ਇੰਸਟੀਟਿਊਸ਼ਨ ਗੱਲਬਾਤ 445
446 ਸਿੱਖਿਆ ਪ੍ਰੋਗਰਾਮ ਸਿੱਖਿਆ ਪ੍ਰੋਗਰਾਮ ਗੱਲਬਾਤ 447
2600 ਵਿਸ਼ਾ 2601
ਬਣਾਵਟੀ ਨੇਮਸਪੇਸਾਂ
-1 ਖ਼ਾਸ
-2 ਮੀਡੀਆ
Current list (API call)

You only ever need to use parameters 3–20 if you want a profile of two or more namespaces for a search domain. Otherwise you can just say the namespace name (or all) at the beginning of the query, or a prefix parameter at the end of the query.

When the query goes through this template, the default search domain is article space, just as it is for basic users. The default search domain of a user, logged-in or not, is article space unless the user set their preference.[3] But no matter who uses a search link the results will always be the same. "Cut and paste" can never guarantee the same results for a search, but a search link can because the search domain is just article space for everyone, or search domain is the set of namespaces you set for everyone.

If you know the numbers of your search domain profile, you just type them in ns=ns0&ns1&ns2600. (You can get them from the namespace table to the right.) Otherwise you refine your query and search domain on the search results page, whose Advanced interface is designed to select and adjust namespaces with no knowledge of the namespace numbers. Once that produces satisfactory results, you copy the namespaces string from the URL (in your browser's address bar), and paste it into |ns=, and you can get the query from the search results page search box, and paste it as the query, and that's your search link.

If you have just one namespace in your search link, and it's not article space, you can specify it by saying, say, ns=ns10, or |ns10" at parameter position 3 or greater:

{{sl|"search link" namespace||ns10}}"search link" namespace

For one namespace the explicit name is preferred:

{{sl|Template:"search link" namespace}}Template:"search link" namespace

The explicit name is preferred if you will be publishing or saving your search link. That way when it is run later the search domain shows up explicitly at the beginning of the search box of the search results page to inform the user. Otherwise only the URL and only the namespace-profile dialog frame pops up on the search results page to inform the user. When it is two or more namespaces, these things always happen, because the query only accepts one namespace (as the first term only). But all is also an informative query, a pseudo-namespace for Search only. If you see a query begin with all:, the URL will be loaded with all the namespace parameters.

You can use "all" in {{Search link}} to specify all namespaces:

{{sl|query|ns=all}}
{{sl|query|label|all}}

but again, it is far more preferable to say

{{sl|all:"search link" namespace}}all:"search link" namespace

than it is to use:

{{sl|"search link" namespace||all}}"search link" namespace

for the reasons given just above. But when specifying "all", the query time is about seven times greater because there are that many more pages on the wiki than there are articles. If a more targeted search is possible, it runs much more quickly than the "all" search.

For example, if you have a query for which know the search domain is 10 and 11, and you want no label, then you need a parameter 3, but you need no parameter 2, so per the template parameter rules the search link can be made in four general ways:

  • {{sl|query||ns10|ns11}} When parameter 1 unnamed, and parameter 2 is unnamed | | (defined as the "empty string"), then parameter 3 can be defined unnamed ns10, and parameter 4 can be defined unnamed ns11, and so on. Nothing is named because everything is defined.
  • {{sl|query|3=ns10|4=ns11}} Parameter 2 is undefined, but that's fine because parameters 3 and above are all named...
  • {{sl|query|ns=ns10&ns11}} or the empty positional parameter | | is not needed when |ns= defines itself named.
  • {{sl|query=query|label=|ns=ns10&ns11}} Everything is explicitly named.

For another example, if you select the "Wikipedia" and "Help" namespaces, then run a query, the URL will show ns4=1&ns12=1. Copy that and paste it to |ns=ns4=1&ns12=1. (Note: you can ignore the "=1" part from the URL.)

Note how the URL contains ns0, ns1, ns2, and ns3, and how it got them:

{{sl|systems operations|3=ns2|4=ns1|ns=ns3|20=ns0}}systems operations
{{sl|query = systems operations|||ns2|ns1|ns3|ns0}}systems operations
{{sl|systems operations|3=ns2&ns1&ns3&ns0}}systems operations

If you need to develop a highly specific search domain, a very elaborate one carved out of a set of the thirty namespaces, then you will have developed this at the search results page using the Advanced search domain picker there. Then you just cut and paste the entire string from the URL of your found search domain namespaces, and paste it into one named parameter |ns=.

To type in namespaces 0, 2, 4, 5, 7 and 9, with no label, the two easiest ways are:

  • {{sl|query||ns0|ns2|ns4|ns5|ns7|ns9}}
  • {{sl|query|ns=ns0&ns2&ns4&ns5&ns7&ns9}}

The order is irrelevant.

Advanced examples

[ਸੋਧੋ]

All these involve insource:/slash delimited regex/ with filters. Any search link with an insource:/regex/ search should always provide the additional query terms that would filter (reduce) the search domain as much as possible. This template defaults to article space if no namespace is given, which is a filter.

Quoting

The need to match an equals in an article is not surprising, and is basic. You have to use {{=}} or |query= or |1= just to get the equals sign in your query to the search engine, or {{!}} to get the pipe character to the search engine. Both pipe characters and the equals signs are template sensitive for all templates, so you can always quote them with curly brackets like that inside templates. Although the search box can take = and | directly, quoting is necessary in the search link because otherwise they have their parameters meaning.

Regex are sensitive to punctuation, brackets, math and other symbolic characters, collectively known as "punctuation" so you quote them, because otherwise they have their regex metacharacter meaning. The "metacharacters" of CirrusSearch have claimed most punctuation characters as functions in their regex, but you don't have to know all the metacharacter functions just to search for them as targets literally. You can simply quote all punctuation to search for them as literal targets in wikitext. The way to easily quote every character in an entire regexp is to put the whole term in quotes: insource:/"regexp with literal characters"/

To get a pipe character through both the template and the search engine to target it as a character in wikitext, you have to quote it twice, hence the frequent need for the six characters \{{!}} in an advanced search link. The equals sign is not a metacharacter, so it does not have to be quoted twice, as the pipe character does. The pipe character is a metacharacter that means OR.

To generate advanced regex searches, see about doing so at {{regex}}. ਮਦਦ:Searching/Featuresਮਦਦ:Searching/Regexਮਦਦ:Searching/Regex/Sandboxing

See also

[ਸੋਧੋ]

Templates for searching Wikipedia

[ਸੋਧੋ]
[ਸੋਧੋ]

A search link stores a query in a link that takes you to live search results for that stored search. They're found on user pages and talk pages. Use one to bring the full feature set of MediaWiki Search, or features of external search engines, to bear on users unfamiliar with their search parameters.

One type of search link is a wikilink with all the capabilities of Search (search box), and with standard wikilink syntax: [[Special:Search/query| label]]. So this search link will (1) navigate: [[Special:search/Wales]] → Special:search/Wales or (2) search: [[Special:search/~Wales | search/~Wales]]search/~Wales if you prefix a ~ tilde character.

All other search links are made from a template that will build a URL instead of wikilink. A URL can for example can call off-site search engines to search Wikipedia.

  • {{Search link}} offers all the capabilities of Searching (search box), plus extra (URL) parameters for combinations of namespaces, and where you can escape the 20-results-per page-limitation, shareable: {{search link | et al | ''label'' | ns4 | ns5 | limit = 123}} label.
  • {{Regex}} – develop an advanced regex search. {{regex | \<--.*--> | label = Articles with comments missing the ! bang character | prefix=0}}ਫਰਮਾ:Regex
  • {{Template usage}} – develop a template regex search, and pinpoint specific template-call details. {{Template usage | Convert | \{{!}}C\{{!}}F | 0 | Articles that convert Celsius to Fahrenheit}}ਫਰਮਾ:Template usage
  • {{ShortSearch}} – create three search links: {{ShortSearch | system operations research}}ਫਰਮਾ:ShortSearch (search Wikipedia, "Google" Wikipedia, and Google search)
  • {{wpsearch}} – create five search links: {{wpsearch|collaborative search}}ਫਰਮਾ:Wpsearch
  • {{Wikidata search link}} – creates a Wikidata search link for descriptions, entities, items, properties, etc. → ਫਰਮਾ:Wikidata search link

Search boxes

[ਸੋਧੋ]

Search boxes are made by <inputbox> tags. See mw:Extension:InputBox.

Page title searches

[ਸੋਧੋ]
  • {{Canned search}} – Link to automated search results for a given term
  • {{In title}} – Search for pages whose name contains given words
  • {{Look from}} – Search for pages whose name begins with a given word

For searches with exact matches, exact in upper and lower cases, or in punctuation marks, see Help:Searching#grep § Notes.

Other Wikipedia editor help

[ਸੋਧੋ]

See also


  1. Some users' default search domain is all namespaces. In cases like the bare regex search, the search engine protects itself by limiting all regex searches. A bare regex that crawls through millions of pages can take over twenty seconds, and may even cost you an HTML timeout. During that time very few other regex searches are allowed. Always use a filter with regex.
  2. Searching for an equals sign requires using a regexp. As with any template, use {{=}} or |1= to pass in an equals sign to any parameter, even the link label.
  3. Advancing editors who begin to search for Wikipedia's other pages may at times set their default search domain (at Special:Search Advanced) to all. Setting search to all is the most likely scenario to "set and forget". Since that includes article space, the usual results are comparable.