我正在使用Zend_Search_Lucene来创建文章索引,以允许在我的网站上搜索它们.每当管理员更新/创建/删除管理区域中的文章时,都会重建索引:
$config = Zend_Registry::get("config");
$cache = $config->lucene->cache;
$path = $cache . "/articles";
try
{
$index = Zend_Search_Lucene::open($path);
}
catch (Zend_Search_Lucene_Exception $e)
{
$index = Zend_Search_Lucene::create($path);
}
$model = new Default_Model_Articles();
$select = $model->select();
$articles = $model->fetchAll($select);
foreach ($articles as $article)
{
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text("title", $article->title));
$index->addDocument($doc);
}
$index->commit();
Run Code Online (Sandbox Code Playgroud)
我的问题是这个.由于我正在重新索引文章并处理已删除的文章,为什么我不是每次都使用"创建"(而不是"打开"和更新)?使用上面的方法,我认为文章每次都会添加addDocument(所以会有重复).我该如何防止这种情况?有没有办法检查文档是否已存在于索引中?
此外,我不认为我完全理解当您"打开"并更新它时索引的工作原理.它似乎每次都在索引文件夹中创建新的#cfs(所以我有_0.cfs,_1.cfs,_2.cfs)文件,但是当我使用"create"时,它会用新的#cfs覆盖该文件.带#递增的文件(例如,只有_2.cfs).你能解释一下这些分段文件是什么吗?
我想git diff
用 VS Code打开一个输出。当我运行时git diff | code -
,它在 VS Code 中打开,但文件扩展名设置为.txt。我可以手动将“更改语言模式”更改为 Diff,但是在 VS Code 中查看差异时如何自动执行此操作。如果可能,我想避免总是将 .txt 与 Diff 相关联。
如何在APC操作码缓存中使用apc.filters参数来缓存某些路径?例如,我希望缓存在路径下的任何内容中都是活动的:
"在/ var/WWW /虚拟主机"
并排除路径
"在/ usr /共享/ PSA-部落/"
我试过用
apc.cache_by_default = 0
apc.filters = "+/var/www/vhosts"
Run Code Online (Sandbox Code Playgroud)
和
apc.cache_by_default = 1
apc.filters = "-/usr/share/psa-horde/"
Run Code Online (Sandbox Code Playgroud)
但都没有像我预期的那样奏效.
http://www.php.net/manual/en/apc.configuration.php#ini.apc.filters
过滤器应该更像"+/var/www/vhosts/*"(注意通配符)吗?由于过滤器的工作方式,我担心这是不可能的:
请注意,用于匹配的文件名是传递给include/require的文件名,而不是绝对路径.
任何想法或样本配置?
我可以使用API进行的请求数量是否有限制?我看到上传的限制和你可以拥有的视频总数(2000),但是我可以对搜索查询方法提出的请求是否有限制?
http://code.google.com/apis/youtube/2.0/reference.html#Searching_for_videos
处理我的第一个Android应用程序.我想知道是否有办法以任何方式在标记中使用xmlns.例如,在Flex中,我可以定义命名空间:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cb="com.typeoneerror.apps.app.views.components.*">
<cb:CustomComponent paramName="demo"></cb:CustomComponent>
</mx:VBox>
Run Code Online (Sandbox Code Playgroud)
Android似乎略有不同.您在定义params时使用命名空间,而不是标记本身.这对我来说有点罗嗦,所以我想知道是否有办法配置或改变这个:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cb="http://schemas.android.com/apk/res/com.typeoneerror.apps.app">
<com.typeoneerror.apps.app.views.components.CustomComponent cb:paramName="demo"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想用
<cb:CustomComponent cb:paramName="demo"></cb:CustomComponent>
Run Code Online (Sandbox Code Playgroud)
可能?
我想在输出的JavaScript文件中保留我在CoffeeScript文件中写的注释.我怎样才能做到这一点?
#!/usr/bin/env bash
./node_modules/.bin/coffee --output lib/ --compile --bare --watch src/
Run Code Online (Sandbox Code Playgroud) 我在我的表头视图部分中有这个:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sectionHeaderTapped:)];
Run Code Online (Sandbox Code Playgroud)
我想传递方法中的节号,sectionHeaderTapped
以便我可以识别哪个部分被轻拍.
我的方法实现如下所示:
-(void)sectionHeaderTapped:(NSInteger)sectionValue {
NSLog(@"the section header is tapped ");
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
Yarn 有一个方便的版本控制配置,允许您在版本控制期间创建标签时配置 git:
yarn config set version-tag-prefix "v"
yarn config set version-git-message "v%s"
Run Code Online (Sandbox Code Playgroud)
但是,我有一个项目,其中包含多个 npm 项目,我想对每个项目进行版本控制project-vn.n.n
,上面似乎是全局设置。
有没有办法为每个 package.json 配置前缀和消息(无需手动指定)?
可能重复:
是否有记录GET/POST参数的标准?
试图找出以有意义的方式通过phpdoc记录请求参数的最佳方法.具体来说,我有一些Zend Framework控制器动作通过GET/POST接收参数,但不是功能参数.这有意义吗?
/**
* Display a pagination/grid list of rows.
*
* @param string $_GET['order'] What field to sort on
* @param string $_GET['dir'] Direction to sort; either ASC|DESC
*
* @return void
*/
public function listAction()
{
$order = $this->_request->order;
...
Run Code Online (Sandbox Code Playgroud)
如果我为此方法生成了文档,则不会指示"order"和"dir"可以通过url字符串传递给此方法.这样做会更有意义吗?
@param string $order
Run Code Online (Sandbox Code Playgroud)
我应该使用@var吗?
欢迎思考.
什么是update
与json字段一起使用的最佳方式.我希望我的JSON字段接受新密钥或更新现有密钥,但不会覆盖整个字段.ActiveRecord可以很好地更新已更改的字段,但我不明白如何将其应用于json记录中的子字段...
it 'can update settings with a plain object' do
integration = Integration.create(
name: 'Name',
json_settings: {
key1: 1,
key2: 2
}
)
integration.update(
settings: { key2: 2 }
)
// json_settings is now { "key2": 3 } but I want
// { "key1": 1, "key2": 3 }
expect(integration.json_settings['key1']).to eq('1') // fails
end
Run Code Online (Sandbox Code Playgroud) php ×4
git ×2
activerecord ×1
android ×1
apc ×1
api ×1
coding-style ×1
coffeescript ×1
diff ×1
iphone ×1
json ×1
lucene ×1
node.js ×1
npm ×1
opcode-cache ×1
phpdoc ×1
postgresql ×1
selector ×1
xcode ×1
yarnpkg ×1
youtube ×1