Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

CodeSearch spice plugin #54

Merged
merged 1 commit into from
Jun 14, 2012
Merged

CodeSearch spice plugin #54

merged 1 commit into from
Jun 14, 2012

Conversation

boyter
Copy link
Collaborator

@boyter boyter commented Jun 12, 2012

Follows from discussion here, #33 where using "example" or "code" as the prefix trigger will cause it to do a code search but listen for languages as the first keyword first and if so restrict to a language search.

Some example searches,

code c# IsNullOrEmpty
code (else (fuck-up)))
code perl goto
code =~
code <<
code if (( index "<>{}:*?+|&^$.", $initchar) >= 0 )
example lua duckduckgo

@ghost ghost assigned moollaza Jun 13, 2012
@moollaza
Copy link
Member

@boyter had a look at the new spice, I tried it out but the searches kept getting eaten by the SearchCode spice. I noticed the new one has a different url for "spice to =>". Will this be the new api for everything? I'm just wondering if we can improve the first by doing a regex check for "example" or "code" and if so just append "lang:" to the query.

@boyter
Copy link
Collaborator Author

boyter commented Jun 13, 2012

Have some example searches? I tried all of the above and they worked as expected. Im curious to see what you were using.

As for the URL, throw a log on the fire and get comfortable. Initially I was just looking getting code documentation searchable. This was put into one index. Code search became a priority after Google Code search was shut down and lives in a separate index. As I have no strategy for blending the results (yet) I have the API's separated out, hence the other URL.

Now, can we combine them. Yes possibly. I still need to figure out how to blend the results however. This is an issue because I need to determine which is the more correct result for things like "mysql_query". Again you run into the "what is the users context" problem which is not easy.

@moollaza
Copy link
Member

@boyter sounds good. The search I was trying was "python socket example" I believe the spice plugins were racing as SearchCode triggered on "python" (or any other language name) and CodeSearch was triggering on "example". I tried a few queries similar to that and each time Duckpan Query showed me SearchCode won every time.

No problem with the separate url's I was just curious to see if we could put it all into one spice. Not a problem though.

@boyter
Copy link
Collaborator Author

boyter commented Jun 14, 2012

Ah it might be because this one is set to only be at the start,

triggers start => "code", "example";

Hence not picking up. If you changed it around to "example python socket" it would totally work as you expect and produce the following results, http://searchco.de/?q=lang%3Apython+socket&cs=on

Id love to pull it into one spice too. I still need to determine if I can combine the indexes at some point or blend them nicely. Its on the list.

@moollaza
Copy link
Member

@boyter I manged to get it working! I just added an unless $_ =~ qr/\b(example|code)\b/i; to SearchCode and made CodeSearch trigger on startend. That way if they race, CodeSearch wins when there is mention of "code" or "example"

moollaza added a commit that referenced this pull request Jun 14, 2012
CodeSearch spice plugin, merging and then adding my small fix
@moollaza moollaza merged commit 90cac50 into duckduckgo:master Jun 14, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants