Re: Beagle,Querying extended properties



Hello!!, I have a problem, I'm trying to put the code on FIleSystemQueryable.cs but I don't know if I'm doing somethig wrong or it just don't work....
I added this code on ExtendedAttribute.cs inside Util directory for listing extended properties...

        public static ArrayList List (string path)
        {
            string[] XPropertiesNames;
            ArrayList XPropertiesList=new ArrayList();
            if(! FileSystem.Exists(path))
                throw new IOException (path);
            Syscall.listxattr (path,out XPropertiesNames);
            for (int i=0 ; i<XPropertiesNames.Length ; i++)
            {
                XPropertiesList.Add (XPropertiesNames[i]);
            }
            return XPropertiesList;
        }
and then added the following method to FileSystemQueryable.cs

       public static void AddExtendedProperties (Indexable      indexable,
                                                                         string         path)
        {
            ArrayList XPropertyList=new ArrayList();
            string XPropertyValue;
            string[] PropertyName;
            XPropertyList=Util.ExtendedAttribute.List(path);
            foreach (string XPropertyName in XPropertyList)
            {
                XPropertyValue=Util.ExtendedAttribute.Get(path,XPropertyName);
                PropertyName=XPropertyName.Split('.');
                indexable.AddProperty(Beagle.Property.New ("xattr:"+XPropertyValue,
                                        PropertyName[PropertyName.Length-1]));
               
            }
        }
and then I make a call to this method on AddFile method
         .
         .
         .
          if (indexable != null) {
                Scheduler.Task task;
                //a call to add extended properties
                AddExtendedProperties (indexable,path);
                //
                task = NewAddTask (indexable);
                task.Priority = Scheduler.Priority.Immediate;
                ThisScheduler.Add (task);
            }
            .
            .
            .
after this, it compile ok, but I don't know if I'm doing somethig wrong querying the extended attributes (maybe I'm querying with wrong syntax) or simply the code I put doesn't work...

Help me please...

2007/6/16, Daniel Labella de la Cruz <dani labella gmail com>:
Thank you Joe for your reply!!!!!!, whe I have a little bit more time, I try to do it following your instructions. Now it's more clear.

2007/6/14, Joe Shaw < joe joeshaw org>:
Hi,

On 6/14/07, Daniel Labella de la Cruz <dani labella gmail com> wrote:
> This is my first time posting on a list and I don't know the procedures to
> post a question....if I make a mistake....sorry....

Nope, this is fine.

> I was reading about, and I think that the Filters can do that. But the
> "problem" is that I want that every file with extended attributes have its
> attributes as searchable properties...

Since extended attributes are file system-specific, I think the right
place to add code for this would be in the file system backend
(FileSystemQueryable) rather than filters.

> Mono.Unix.Native.Syscall.listxattr(info.FullName,out
> XProperties);

There is already a class in Beagle for working with extended
attributes: Beagle.Util.ExtendedAttribute.  You should use that
instead, and add anything to it that you need.  (For example, I don't
think there is code to list them.)

> AddProperty(Beagle.Property.NewKeyword("dc:"+PropertyName[PropertyName.Length-1
> ] , XValue.Trim('\0')));

"dc" is specifically the "Dublin Core" namespace; see dublincore.org
for more info.

You should probably name it something like "xattr:" + the property name.

> With this I can see the extended properties with beagle-extract-content, but
> I can't search by property:value...

If you want generic text searches to match, you need to use the
Beagle.Property.New () method instead of NewKeyword().  Keywords are
for exact matches.

If you want to add a special keyword in the search language (like how
we have "album:foo" in the search match to "dc:album" = "foo"), then
you need to use the PropertyKeyword attributes.  Look at other filter
or backend instances to see how to declare those.

Joe




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]