Answer the question
In order to leave comments, you need to log in
How to correctly add an attribute to the Sphinx index?
I form the XML:
$xmlwriter = new xmlWriter();
$xmlwriter->openMemory();
$xmlwriter->setIndent(true);
$xmlwriter->startDocument('1.0','UTF-8');
$xmlwriter->startElement('sphinx:docset');
$xmlwriter->startElement('sphinx:schema');
$xmlwriter->startElement('spinx:attribute');
$xmlwriter->writeAttribute("name", "path");
$xmlwriter->writeAttribute("type", "string");
$xmlwriter->endElement(); // attr
$xmlwriter->startElement('sphinx:field');
$xmlwriter->writeAttribute("name", "content");
$xmlwriter->endElement(); // field
$xmlwriter->endElement(); // schema
$xmlwriter->startElement('sphinx:document');
$xmlwriter->writeAttribute("id", 1);
$xmlwriter->writeAttribute("path", "TEST_ATTRIBUTE");
$xmlwriter->startElement("content");
$xmlwriter->text("TEST_CONTENT");
$xmlwriter->endElement(); // field
$xmlwriter->endElement(); // doc
$xmlwriter->endElement(); // docset
print $xmlwriter->outputMemory(true);
<?xml version="1.0" encoding="UTF-8"?>
<sphinx:docset>
<sphinx:schema>
<spinx:attribute name="path" type="string"/>
<sphinx:field name="content"/>
</sphinx:schema>
<sphinx:document id="1" path="TEST_ATTRIBUTE">
<content>TEST_CONTENT</content>
</sphinx:document>
</sphinx:docset>
# indexer --rotate --all
Sphinx 2.2.11-id64-release (95ae9a6)
indexing index 'test1'...
WARNING: Attribute count is 0: switching to none docinfo
collected 3 docs, 0.0 MB
Answer the question
In order to leave comments, you need to log in
Understood:
$xmlwriter = new xmlWriter();
$xmlwriter->openMemory();
$xmlwriter->setIndent(true);
$xmlwriter->startDocument('1.0','UTF-8');
$xmlwriter->startElement('sphinx:docset');
$xmlwriter->startElement('sphinx:schema');
$xmlwriter->startElement('sphinx:field');
$xmlwriter->writeAttribute("name", "content");
$xmlwriter->endElement(); // field
$xmlwriter->startElement('sphinx:attr');
$xmlwriter->writeAttribute("name", "path");
$xmlwriter->writeAttribute("type", "string");
$xmlwriter->endElement(); // attr
$xmlwriter->endElement(); // schema
$xmlwriter->startElement('sphinx:document');
$xmlwriter->writeAttribute("id", 1);
$xmlwriter->startElement("content");
$xmlwriter->text("TEST_CONTENT2");
$xmlwriter->endElement(); // field
$xmlwriter->startElement("path");
$xmlwriter->text("TEST_ATTRIBUTE2");
$xmlwriter->endElement(); // attr
$xmlwriter->endElement(); // doc
$xmlwriter->endElement(); // docset
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question