If you work with SharePoint Portal Server 2003, you’ve probably messed around a bit with creating web parts or maybe automating some of the routine administration tasks, but have you tried accessing the search web service?

There are articles out there telling how to integrate the search web service with the Office 2003 Research Pane, there’s documentation on the schemas for querying the search service, but if you look at the SDK documentation, there’s really no example for what the query itself should look like. I mean, I can figure out how SQL Server full-text queries work, but what’s the source I’m querying? When you put everything together, what are you really sending to the web service, and, more importantly, what’s coming back?

To answer this, you could use something like SOAPscope and start watching packets that way, but you’re still going to be putting things together in a sort of trial-and-error fashion, hoping your packet is formed right, etc.

Instead, I created a little app specifically for this: Give it the URL of your server’s search web service, enter your search terms (the keywords for a “keyword” search; the SQL full-text query SELECT statement for a “SQL Fulltext” search) and click “Execute Query” - the program goes out to your search service, registers to search, gets the list of available catalogs and search scopes, and executes your query. You can see the form the query packet takes and the results you received from that query. You also have the option of changing search settings to different limits - start at a particular record number in the results, retrieve a certain number of results, only retrieve certain types of results, etc.

SPS Search Test - Displaying the query
packet

Note: While this is a very helpful tool to test out queries and see if they work, I still don’t have any real documentation about the form of full-text queries for SPS. I’m working on getting some information from Microsoft on this, to find out which fields I can query for/against and how to determine that for different servers, as well as figuring out what different errors mean. When I have more, I’ll update this entry. (The only queries I’ve gotten to work are variations on SELECT "DAV:href" FROM Non_Portal_Content..SCOPE() WHERE size > 0 so… I’ll keep you posted. It doesn’t seem to work like the SPS 2001 queries did, though.)

UPDATE: 6/18/04 11:00 AM - It turns out they embed the entire SQL query that gets run on the Advanced Search page right in the source.

Also, I’ll be updating the app as I learn more about the search functionality so I can offer more flexibility in the querying.

Download SPSSearchTest 1.1.0 (MSI)

Download SPSSearchTest Source 1.1.0 (ZIP)

Version History 1.1.0:

  • Added syntax highlighting for SQL queries using the ICSharpCode.TextEditor control.
  • Moved view and query options into menus.
  • Now showing the Registration Request packet. 1.0.1 - First public release. 1.0.0 - Internal/unreleased version (still needed more functionality for prime time).

media, movies comments edit

Jenn and I watched Punch-Drunk Love via On-Demand last night.

Boy, am I glad I didn’t pay for that one.

Adam Sandler plays this guy Barry who is sort of antisocial… but sort of not. Really, I couldn’t tell what was wrong with him. He had these random fits of rage, sometimes he was well adjusted and sometimes not… I dunno. Anyway, Barry calls this phone sex line and winds up being the victim of this ridiculous extortion scam. While he’s dealing with that, he meets this girl named Lena (played by Emily Watson) with whom he falls in love.

Sounds okay, right? Except for the fact that there are these weird non-sequiturs throughout the whole thing. For example, at the beginning Barry’s standing outside his business, drinking coffee, watching traffic. Out of nowhere, this SUV flips over onto its roof and slides down the street at the same time this taxi cab/van drives up and drops off a harmonium on the sidewalk.

Normally I’d be cool with this - an obvious, but potentially flawed metaphor for love: bang! something hits you and you end up with a little harmony. The thing is, this is actually happening in the movie; it’s not something in Barry’s mind. And he ignores it! All of these things happen, and we’re supposed to accept there’s basically no big deal.

Not only that, but there are these weird interstitials strewn throughout the movie with odd colors and lights on the screen and music playing… I have no idea what that was all about.

“No, it’s surrealism!” I hear you screaming. Maybe it’s me. It wasn’t consistently surreal, so I can’t give ‘em credit for the one-off attempt. I have to chalk it up as straight weirdness.

Maybe I just didn’t get it. Maybe I’m too “thick” for this kind of movie. I’d like to think it’s more because the movie missed its mark, but this is the avant-garde crap that critics seem to faun over. I can’t tell you how many reviews I’ve seen where the end is something like “this is the film to see!” or “a fresh breath from the norm!” Ugh. I’m all about art in films, but when the one overshadows the other, you lose me.

Pass on this one. Or see it when you’re smoking crack, because then the flashing lights and colors with the music might seem cool. It wasn’t for me, though.

sharepoint comments edit

It has come to my attention that at this time there are no real documents out there (at all - even internal to Microsoft) that discuss the ins and outs of querying SPS 2003 via the search web service and fulltext search queries. Nobody seems to have the magic answer as to how to formulate the query - what you can SELECT, what goes in the WHERE clause, etc.

I don’t have the answer, but I know how you can get a jumpstart on figuring out how it works.

On the SharePoint Portal Server 2003 “advanced search” page (the one that allows you to search over document metadata), do a search. Once you get the results you want, do a “View Source.” Scroll down near the bottom (or search for “SELECT” - match the upper case letters, too) and check this out: They embed the entire SQL full-text query right in the page.

Apparently that’s how the MS guys figure out how the thing works; if it works for them, it should work for you, too. Good luck!

gists, php, blog comments edit

I had a problem where I wanted to add a pMCode tag in pMachine to allow me to automatically link to other pages on my site. For example, normally you can use [url=http://somesite.com]linktext[/url] to create links to other sites… but what if you want to link to pages in your own site? Adding hard references like that makes the site sort of inflexible if you change your URL or move to a different server (which is the problem I had). Wouldn’t it be nice if you could link to, say, your comments page by doing something like this: [commentlink=123]linktext[/commentlink]

So that’s what I drummed up. It seems to work for my site, which only hosts one blog, but it should work for multi-blog sites, too. To enable this change, you’ll need to edit your /pm/lib/pmcode.fns.php file.

At the top of the pmcode_decode function, add the following:

global $weblog;

Now add the following lines as shown, around line 305 in the file, with the rest of the substitutions:

// [commentlink=123]sometext[/commentlink]
$str = preg_replace("/\[commentlink=(.*?)\](.*?)\[\/commentlink\]/i", "<a href=\"" . get_comments_link('\\1', $weblog) . "\">\\2</a>", $str);

Then copy and paste the following function in that same file, somewhere toward the bottom:

function get_comments_link($postid, $weblog = ""){
 global $db_multiweblogs, $db_categories, $db_weblog;
 global $db_members, $db_upload_prefs, $db_nonmembers, $pingserver_path;
 global $db_comments, $profileviewpage, $auto_xhtml, $url_rewriting, $sfx;

 if ($weblog == "") $weblog = "weblog";

 $db = new DB();
 $blogid_array = array();
 $sql = "select id,weblog from $db_multiweblogs order by id";
 $query = new DB_query($db, $sql);

 while ($query->db_fetch_object())
 {
  $blogid_array[$query->obj->weblog] = $query->obj->id;
 }

 unset($query);
 unset($sql);

 $catpage = (isset($blogid_array[$blog]))  ? $blogid_array[$blog] : "1";
 $pagespath = get_pref("pages_path_abs_$weblog","1");
 $comments_page = get_pref("comments_page_$weblog");

 $delim = '?id=';

 if ($url_rewriting == 1)
 {
  $delim = '/';
  $comments_page = str_replace($sfx, '', $comments_page);
 }

 $catrow     = 0;

 $comments_url = "$pagespath{$comments_page}$delim$prefix{$postid}_0_{$catpage}_{$catrow}_C";

 if ($url_rewriting == 1) $comments_url .= '/';

 return $comments_url;
}

That should do it. Now you can use the new “commentlink” pMCode tag. Just pass in the ID to the entry you want to link to, like this: [commentlink=123]linktext[/commentlink]

Good luck!

I know enough about myself to admit my weaknesses and know the boundaries on my abilities. For example, I have very little patience with people. I already know I have this flaw, and I do my best to accommodate for it by avoiding situations where it may require I have a lot of patience in regards to socializing with others. I try to spare myself - and everyone else - the pain of having to deal with me once my patience wears out.

See, for me, patience is sort of like a bank account: You have a certain amount of patience, you spend it on different situations, and when you’re out, you’re out - time to back off and build up some more patience in the old account.

Teaching people is like going on a patience spending spree. I get spending long before I even get to the teaching part. I start thinking about all the different stupid shit the person I will eventually be teaching will want to know, then I get thinking about how I’m going to answer the questions - particularly technical questions from a non-technical person - and pretty soon I’m already stressed out and pissed off.

Putting this into perspective, I just got off a very, very long project at work that pretty much kept my patience bank at a low level. I got by, but barely, and I look back on it now as a trial that I successfully overcame; I’m happy with the end product, I’m happy with the team I worked with, and I’m happy that we were able to succeed. That said, I need a little time before jumping right back into the fire so I can build my patience account back up. I’m fresh out. Plus, now that I’m working on a different project, I’d like to actually make some headway on the new project, not continually context-switch back to the old project.

I got word today that we’ve got a non-technical guy who needs to be educated on how to do some reasonably technical stuff to customize the output of my last project. To that end, I’ve been tasked to train this guy on how to do the changes, then potentially have a meeting where I train a room full of these people.

Asking for this is akin to saying “We have a whole bunch of people who don’t know how the web works; in two hours or less, you need to teach them how to make web pages using cascading style sheets.” At the very best, my patience bank just got robbed for whatever was left; more likely, I’m going to end up shooting all these people and then shooting myself.

You might ask yourself what the big deal is. The problem is in the way I work. My mind moves very quickly and not necessarily in a straight line from point A to point B. In fact, there are usually about 20 different points in between that I stop at on the way. This doesn’t translate well in a training environment for things where there’s not actually a process to follow. In many cases, I don’t even know how I got from point A to point B - there was a path, there was some method to the madness, but articulating that is beyond my abilities. This trait became problematic in college math classes where I’d write out the problem then the solution right after; you’re supposed to show your work but I don’t know how I got the answer, I just knew what the answer was.

It’s the articulation of the path that blasts away my patience. If I slow down enough to explain the exact thought process going on, I lose track of where I am and don’t actually accomplish anything. Ever start to say something and then forget what you were going to say right as you were going to say it? It’s like that. I’m like, “Okay, first you do this, then… uh… what were we working on?”

Note that this is different if I have a curriculum to teach and there’s a process to be followed. When it’s not “train this entirely non-technical person on a totally unstructured technical topic,” I do reasonably well. I can answer questions, follow a curriculum, and all is well. It’s when I have to get into defining a process for how to do something at the same time I’m trying to teach the person how to do it that really gets me… the impromptu requests for training on topics that have no curriculum, process, or structure. That’s where we have issues.

Anyway, I’m doing my best to make my displeasure at this training idea known without overtly pissing too many people off. I’m quickly coming upon the time where I won’t care about who I piss off, though, and that could be career limiting. Here’s hoping I don’t end up getting fired, eh?