Add stringification to corpusByMatch query

Change-Id: I223e838d622465994ed0177e29bd7a73db9a0728
diff --git a/dev/js/src/match/corpusByMatch.js b/dev/js/src/match/corpusByMatch.js
index 59038a0..050ecb7 100644
--- a/dev/js/src/match/corpusByMatch.js
+++ b/dev/js/src/match/corpusByMatch.js
@@ -49,14 +49,14 @@
       // Meta information is a single value
       if (target.tagName === 'DD') {
         type = target.getAttribute("data-type");
-        key  = target.previousSibling.innerText;
+        key  = target.previousElementSibling.innerText;
         value = target.innerText;
       }
 
       // Meta information is in a list
       else if (target.tagName === 'DIV') {
         type = target.parentNode.getAttribute("data-type");
-        key = target.parentNode.previousSibling.innerText;
+        key = target.parentNode.previousElementSibling.innerText;
         value = target.innerText;
       };
 
@@ -64,6 +64,8 @@
       if (type === "type:store")
         return;
 
+      type = type || "type:string";
+      
       // Add or remove the constraint to the fragment
       if (key && value) {
         if (target.classList.contains("chosen")) {
@@ -94,8 +96,8 @@
     },
 
     // Stringify annotation
-    toString : function () {
-      return '';
+    toQuery : function () {
+      return this._fragment.toQuery();
     }
   };
 });
diff --git a/dev/js/src/vc/fragment.js b/dev/js/src/vc/fragment.js
index a623549..a03e845 100644
--- a/dev/js/src/vc/fragment.js
+++ b/dev/js/src/vc/fragment.js
@@ -145,6 +145,19 @@
         e.appendChild(root);
         
       return this;
-    }      
+    },
+
+    toQuery : function () {
+      if (this._operands.length === 0)
+        return '';
+
+      let str = '(' + this._operands.map(
+        function (item) {
+          return item[0] + ' = "' + new String(item[1]).quote() + '"';
+        }
+      ).join(" & ");
+      
+      return str + ')';
+    }
   }
 });